jquery - How to detect top right bottom left screen area JavaScript -


enter image description here

how detect top right bottom left screen area javascript? have 4 arrow slider wanna display when mouse hover on particular area.

$('.container').mousemove(function (e) { if (e.clienty < $('.container').height() / 2) {     console.log('top'); } else {     console.log('bottom'); } if (e.client x < $('.container').width() / 2) {     console.log('left'); } else {     console.log('right'); } }); 

would consider css :hover suggestion? may simpler. added font awesome arrows example.

html,  body {    height: 100%;    width: 100%;  }  .top {    position: absolute;    top: 0;    left: 0;    width: 100%;    height: 40px;    background: lightgray;  }  .left {    position: absolute;    top: 40px;    left: 0;    bottom: 40px;    width: 40px;    background: lightgray;  }  .right {    position: absolute;    top: 40px;    right: 0;    bottom: 40px;    width: 40px;    background: lightgray;  }  .bottom {    position: absolute;    bottom: 0;    left: 0;    right: 0;    width: 100%;    height: 40px;    background: lightgray;  }  .top:hover,  .left:hover,  .right:hover,  .bottom:hover {    cursor: pointer;    background: gray;  }  .top:hover i,  .left:hover i,  .right:hover i,  .bottom:hover {    display: block;  }  i.fa {    display: none;    text-align: center;    line-height: 40px;    font-size: 24px;  }  i.fa.fa-arrow-right,  i.fa.fa-arrow-left {    position: absolute;    top: 50%;    transform: translate(50%, -50%);  }
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />  <div class="top"><i class="fa fa-arrow-up"></i></div>  <div class="left"><i class="fa fa-arrow-left"></i></div>  <div class="right"><i class="fa fa-arrow-right"></i></div>  <div class="bottom"><i class="fa fa-arrow-down"></i></div>


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -