navigating the webpage using the mouse scroll bar

Upon clicking and dragging the button upwards at the bottom of the screen using a mouse, I expect the lock screen to close and the new page to appear.

The next page that will open directly after this action is "Page to open"

I attempted to achieve this functionality with mouseup and mousedown events but was unsuccessful. Watch the complete example video demonstrating the desired function

Streamable

.container {
  position: absolute;
  display: flex;
  right: 40px;
  bottom: 40px;
}

.Phone-container {
  position: absolute;
  width: 285px;
  height: 580px;
  border-radius: 30px;
  overflow: hidden;
}

.Phone-Background {
  background-image: url('https://firebasestorage.googleapis.com/v0/b/fotos-3cba1.appspot.com/o/wallpaper.jpg?alt=media&token=059229cc-3823-4d27-834a-7b62cabd69d2');
  background-size: cover;
  background-repeat: no-repeat;
  right: 0;
  bottom: 0;
}

.unlockBar {
  position: absolute;
  width: 40%;
  height: 4px;
  border-radius: 20px;
  right: 30%;
  top: 565px;
  background-color: rgba(255, 255, 255, .7);
  opacity: 0;
  transition: ease all 0.2s;
  cursor: grab;
}

.Phone-container:hover .unlockBar {
  opacity: 1;
}

.Phone-container .unlockBar:hover:before {
  opacity: 1;
  transform: none;
}

.Phone-container .unlockBar::before {
  content: attr(data-msj);
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  max-width: 100px;
  margin: 0 auto;
  padding-bottom: 10px;
  color: #fff;
  font-size: 12px;
  text-align: center;
  opacity: 0;
  transform: translateY(0px);
  transition: ease all .8s;
}
<div class="container">
  <div class="Phone-container Phone-Background">

    <div class="unlockBar" data-msj="Swipe Up to Open"></div>

    <div class="Page to open">
    </div>
  </div>
</div>

Answer №1

If you're looking to detect a swipe gesture, scrolling won't cut it for this scenario.

For more information on how to achieve this, check out the following resource:

Detect a finger swipe through JavaScript on the iPhone and Android

document.addEventListener('touchstart', handleTouchStart, false);        
document.addEventListener('touchmove', handleTouchMove, false);

var xDown = null;                                                        
var yDown = null;                                                        

function handleTouchStart(evt) {                                         
    xDown = evt.originalEvent.touches[0].clientX;                                      
    yDown = evt.originalEvent.touches[0].clientY;                                      
};                                                

function handleTouchMove(evt) {
    if ( ! xDown || ! yDown ) {
        return;
    }

    var xUp = evt.originalEvent.touches[0].clientX;                                    
    var yUp = evt.originalEvent.touches[0].clientY;

    var xDiff = xDown - xUp;
    var yDiff = yDown - yUp;

    if ( Math.abs( xDiff ) > Math.abs( yDiff ) ) {/*most significant*/
        if ( xDiff > 0 ) {
            /* left swipe */ 
        } else {
            /* right swipe */
        }                       
    } else {
          if ( yDiff > 0 ) {
             /* up swipe */ 
         } else { 
             /* down swipe */
         }                                                                 
     }
      /* reset values */
       xDown = null;
       yDown = null;                                             
 };

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Padding will not completely fill the <li> and <div> elements

Looking to create a sleek menu bar that's 40px tall and fills up 80% of the browser width. The challenge arises when trying to center the text within the menu items. Despite adjusting padding for alignment, there's still a small gap because of & ...

Observing a class getter within Vue.js

The issue at hand I am facing a challenge in ensuring my page automatically updates when new data is available. I am using Ionic, and have a page that displays all the items collected by the user in a visually appealing manner using an ion-grid. To achiev ...

Creating a custom Bootstrap 4 tooltip within a table in an Angular 8 application using a for loop

I've been attempting to integrate an HTML tooltip into a table, but I've encountered some issues. Below is the content delivery network (CDN) that I included: <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstra ...

Encountering Connectivity Issues with Swift 2.0 Multipeer Connectivity

I have a question about a Multipeer Connectivity app that I created following a tutorial. I made some modifications to the code to make it compatible with Swift 2.0. Everything seems to be working fine, but I am facing an issue where my simulation does not ...

Display a modal dialog using HttpInterceptor

@Injectable() export class MyInterceptor implements HttpInterceptor { intercept(req : HttpRequest<any>, next : HttpHandler) : Observable<HttpEvent<any>> { //display a modal dialog to wait for user response before proceeding with t ...

Embed a React component within another component

Recently, I've started learning React and I'm utilizing material-ui for my project. My goal is to create a customized autocomplete feature in React where selected data from the dropdown will appear as chips inside the text input field. I am curre ...

What might be the reason for the border not reaching the bottom of the popup in my chrome extension?

I am currently working on a Chrome extension and using Bootstrap 5 with Sass to style its popup. However, I have encountered an issue where the border of the popup does not extend to the bottom as expected. What could be causing this problem? popup.html & ...

Tips for using CSS to position a sidebar on the right side of the screen:

I've been working on creating a simple sidebar and have reached this point in my code. However, I'm struggling to get it to float to the right. It's all a bit confusing for me. If you'd like to take a look at the code, here is a link t ...

utilize javascript variables within an HTML document

I keep encountering a strange error (Express 400 Error: Bad Request) Some lines are translated to the variable value, while others just output an error. This is an example of my code: exports.add_comment = function(req, res){ var id = req.params.id; ...

Enable lodash access throughout a React Native application

Is it possible to have lodash automatically accessible in all files within a React Native project without needing to import it every time? ...

How can I stop the CSS border of an iframe from flickering and what are some solutions to fix it?

I am encountering an issue with my iframe border when using CSS. The problem arises in Chrome where the border disappears upon resizing the page, while Safari changes the size (Firefox appears unaffected) https://i.sstatic.net/ZUi9z.gif Are there any kno ...

The CSS attribute for setting the background color of Shell in css/default.css does not produce any visible

Currently working my way through the book "Eclipse 4 Plug-in Development by Example Beginner's Guide", specifically on the section titled "Time for action – styling the UI with CSS". The guide instructs to edit the "css/default.css" file and add th ...

What are the steps to create a resizable and draggable reactstrap modal with changing content?

How can I create a resizable and draggable Reactstrap modal with dynamic content from another component? Here is my current code: <Draggable> <Modal isOpen={modal} toggle={this.toggle}> <ModalHeader toggle={this.toggle}> ...

Looking to generate a computed attribute?

Trying to adjust the font size of text using a dropdown and so far it's working as expected. However, is there a more efficient way to achieve this, such as using a computed property or watcher? I'm not sure how to go about implementing that. He ...

I'm having a hard time understanding how to use array_filter()

<html> <style> h1 { text-align: center; } div { text-align: center; border: 1px solid; padding: 20px; width: 520px; margin: 0 auto; } table{ text-align: center; border: 1px solid; padding: 20px; width: 5 ...

Close the material-ui popper when clicking away

I am currently working on implementing a Material UI popper feature that should close when the user clicks outside of it using ClickAwayListener. However, I have been unable to make this functionality work despite trying different approaches. I've att ...

Error encountered: EISDIR when using the "Cordova encrypted file plugin"

Recently, I encountered an issue with my ionic application built using ionic V1. A persistent EISDIR error keeps appearing whenever I try to build it. Upon investigating, I discovered that the culprit behind this error is the cordova-plugin-crypt-file. Dis ...

My jQuery code is encountering issues with the .each loop functionality

I have encountered an issue with the code snippet below, which is intended to hide the "IN STOCK" phrase on specific vendors' product pages. Upon testing, I noticed that the loop doesn't seem to be executing as expected when using console.log. Ca ...

Running an AJAX request in a Flask application's select box onchange event: A guide

I'm working on a Flask app that has multiple select boxes. Each select box should populate with data based on the selection made in the previous select box. I plan to use AJAX for this functionality, where each select box will be submitted upon the on ...

What is the reason behind one function triggering a re-render of a component while the other does not in Next.js?

I am currently working on a Next.js web application where one of the pages contains two functions that utilize useState() to add or remove emails from an array. const [invites, setInvites] = useState([]) // other code const lmao = () => { console.lo ...