在屏幕上滑动覆盖

时间:2016-01-19 16:08:42

标签: javascript jquery html css touch

我为触摸屏信息亭创建了一个简单的网页。主页有一个全屏覆盖,当触摸时,滑动屏幕(使用 animate.css )。

我现在想要一些额外的功能(以提高可用性)。用户是否可以从屏幕上轻扫覆盖屏幕,而不是触摸它并让它“滑开”。我注意到有些用户在第一次接近屏幕时本能地向左/向右滑动。当这不起作用时,假设它已经坏了,其中一半会走开,而不是想用一根手指触摸屏幕。

  • 如果用户向左滑动,则叠加层应从屏幕向左滑动。
  • 如果用户向右滑动,叠加层应从屏幕向右滑动。
  • 如果用户向上滑动,叠加层应从屏幕滑落到顶部。

我一直在看this jQuery plugin - 这会有用吗?

我不知道如何合并这样的功能。然而,到目前为止,我有created a jsfiddle我的工作(为了示例目的而被剥离)。还包括我的所有代码(重复jsfiddle)。

感谢任何帮助或指导。

HTML

<body>
  <!-- start overlay -->
  <div class="overlay overlay-data">
    <div class="container-fluid">
      <div class="row">
        <div class="col-md-12 overlay-info">
          <p class="help-heading">Help?</p>
          <div class="circle"></div>
          <div class="pulse-ring"></div>
        </div>
      </div>
    </div>
  </div>
  <!-- end ovberlay-->
  <div class="container text-center">
    <!-- first row -->
    <div class="row">
      <div class="col-md-4">
        <div class="menu-item blue" id="loader1">
          <a href="#"><i class="fa fa-map-signs big-icon"></i>
                    <p>Guides</p></a>
        </div>
      </div>
      <div class="col-md-4">
        <div class="menu-item blue" id="loader4">
          <a href="#"><i class="fa fa-shopping-cart big-icon"></i>
                    <p>Borrowing</p></a>
        </div>
      </div>
      <div class="col-md-4">
        <div class="menu-item blue" id="loader7">
          <a href="#"><i class="fa fa-binoculars big-icon"></i>
                    <p>Finding books</p></a>
        </div>
      </div>
    </div>
    <!-- end first row -->
  </div>
  <!-- Start Main Body Section -->
  <div class="mainbody-section text-center">
    <div class="partners">
      <!-- Modal -->
      <div aria-labelledby="myLargeModalLabel" class="modal fade bs-example-modal-lg" id="navModal" role="dialog" tabindex="-1">
        <div class="modal-dialog modal-lg">
          <div class="modal-content">
            <hr>
            <h4 class="modal-title" id="navModalLabel">
                        Navigation</h4><img src="images/bs_touchscreen_nav.jpg">
            <div class="modal-footer">
              <button class="btn btn-default" data-dismiss="modal" type="button">Close</button>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- end main body -->
  </div>
</body>

JS

$(document).ready(function() {
  $(".overlay").addClass('overlay-open');
  $("section, .container").addClass('blur');
});

$(document).on('click', '.overlay', function() {
  $('.overlay').addClass('animated slideOutUp');
  $("section, .container").removeClass('blur');
});

CSS

body {
  background-attachment: fixed;
  background-size: cover;
  background-position: 50% 50%;
  font-family: 'Open Sans', sans-serif;
  outline: 0;
}

html,
body {
  height: 100%
}

.btn-primary {
  border-color: #FF432E;
  background-color: #FF432E;
  text-transform: uppercase;
  font-weight: 300;
  color: #fff;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  -o-border-radius: 3px;
  border-radius: 3px;
  -webkit-transition: all 0.3s;
  -moz-transition: all 0.3s;
  -o-transition: all 0.3s;
  transition: all 0.3s;
}

.blue {
  background: #28ABE3;
}

.menu-item {
  color: #fff;
  padding-top: 45px;
  padding-bottom: 45px;
  margin-bottom: 30px;
  -webkit-transition: all 0.3s;
  transition: all 0.3s;
  border: 5px solid transparent;
}

.menu-item:hover {
  border: 5px solid rgba(255, 255, 255, 0.70);
}

.menu-item a {
  color: #fff;
  display: block;
  -webkit-transition: all 0.3s;
  transition: all 0.3s;
}

.menu-item a p {
  font-weight: 300;
  font-size: 25px;
}

.menu-item a i {
  font-size: 50px;
  padding-bottom: 20px;
}

.menu-item:hover a {
  text-decoration: none;
}

.blur {
  -webkit-filter: blur(4px);
}

.overlay {
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background: #000;
  z-index: 1;
}

.overlay p {
  text-align: center;
  position: relative;
  top: 10%;
  height: 30%;
  font-size: 120px;
  color: white;
  font-family: 'Playfair Display', serif;
}

.overlay-data {
  opacity: 0;
  visibility: hidden;
  -webkit-transition: opacity 0.5s;
  transition: opacity 0.5s;
  visibility: 0s 0.5s;
  transition: opacity 0.5s, visibility 0s 0.5s;
}

.overlay-open {
  opacity: 0.5;
  visibility: visible;
  -webkit-transition: opacity 0.5s;
  transition: opacity 0.5s;
}

.overlay-info {
  padding-top: 100px;
}

.circle {
  padding: 100px;
  position: relative;
}

.pulse-ring {
  //content: '';
  width: 400px;
  height: 400px;
  border: 10px solid #fff;
  border-radius: 50%;
  position: relative;
  top: -110px;
  left: 0;
  margin: auto;
  animation: pulsate infinite 1s;
}

@-webkit-keyframes pulsate {
  0% {
    -webkit-transform: scale(1, 1);
    opacity: 1;
  }
  100% {
    -webkit-transform: scale(1.2, 1.2);
    opacity: 0;
  }
}

1 个答案:

答案 0 :(得分:1)

您可以考虑使用支持滑动事件的jQuery Mobile UI:api.jquerymobile.com/swipe

然后,您可以根据操作添加所需的animate.css类:)