Skip to content

isaaxite/parallax_scrolling_flip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

parallax_scrolling_flip

纯js(ES5)实现的视差翻页滚动,核心代码在/src/core/目录下

预览

例子

引入

<script src="./src/core/iflip.min.js"></script>

使用

最简单

<style>
  #app > .mash, #app > .story{ position: absolute;top: 0;right: 0;bottom: 0;left: 0; }
  #app > .mash{ z-index: 2000; }
  #app > .story{ z-index: 1000;overflow-x: auto;overflow-y: hidden; white-space: nowrap;font-size: 0;letter-spacing: 0; }
</style>

<body>
  <div id="app">
    <dl class="mash"></dl>
    <dl class="story">
      <dt></dt>
      <!-- ... -->
      <dt></dt>
    </dl>
  </div>
</body>

<script>
  var gesture = new iGesture({
    mashEl: "#app > .mash",	// 上层视图
    storyEl: "#app > .story"	// 下层元素
  });
</script>

全部功能

var tool = new iTool();
var gesture = new iGesture({
  mashEl: "#app > .mash",	// 上层视图
  storyEl: "#app > .story",	// 下层元素
  validFlipDistance: 60,	// 最小有效偏移距离
  frameDistance: 20,		// 偏移距离(px)/帧
  afterTouchstart: function(touch) {	
    console.log("touchstart: ", touch);
  },
  touchmoving: function(touch, distance) {
    console.log("touchmoving");
  },
  afterTouchend: function(currentPage, isValidLastPage) {
    console.log("touchend");
  }
});

(function _init(){
  tool.forbidSpringback();
})();

About

纯js(ES5)实现的视差翻页滚动

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published