onepage_scroll_rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bb8eac687c91e89c3ec275a800f7139dabcee0d5
4
+ data.tar.gz: 907318289e8331c76906c4b765cfe041bd63cea7
5
+ SHA512:
6
+ metadata.gz: 6e8a3b3904509d091147eda139d864ac84e8be358372a358833bb12b3ba919520c7a577d6024afbb9c35e93a03b9bbc2b82bd095db273c0efb74f9d1a5269edc
7
+ data.tar.gz: b0067bf14564370f7fc005f2814f9824bc6c7e5137b27f5dbfa406a5696a9cea8ea994c97879576002a08d485857b0452e3bad58b9ed70e1524786a535e6f0ae
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ onepage_scroll_rails
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.2.2
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in onepage_scroll_rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Alexander Kiseliev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # OnepageScrollRails
2
+
3
+ Adding [onepage-scroll](https://github.com/peachananr/onepage-scroll) in rails assets.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'onepage_scroll_rails'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install onepage_scroll_rails
20
+
21
+ ## Usage
22
+
23
+ Add in application.css
24
+
25
+ ```sass
26
+ @import 'onepage-scroll/onepage-scroll'
27
+ ```
28
+
29
+ Add in application.js
30
+
31
+ ```coffee
32
+ #= require 'onepage-scroll/jquery.onepage-scroll'
33
+ ```
34
+ or
35
+ ```coffee
36
+ #= require 'onepage-scroll/jquery.onepage-scroll.min'
37
+ ```
38
+
39
+ Use it like [here](https://github.com/peachananr/onepage-scroll). Docs and more info is placed [here](https://github.com/peachananr/onepage-scroll) too.
40
+
41
+
42
+ ## Development
43
+
44
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
45
+
46
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
47
+
48
+ ## Contributing
49
+
50
+ Bug reports and pull requests are welcome on GitHub at https://github.com/enjoycreative/onepage_scroll_rails.
51
+
52
+
53
+ ## License
54
+
55
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "onepage_scroll_rails"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,4 @@
1
+ module OnepageScrollRails
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module OnepageScrollRails
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,2 @@
1
+ require "onepage_scroll_rails/version"
2
+ require "onepage_scroll_rails/engine"
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'onepage_scroll_rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "onepage_scroll_rails"
8
+ spec.version = OnepageScrollRails::VERSION
9
+ spec.authors = ["Alexander Kiseliev"]
10
+ spec.email = ["dev@enjoycreative.ru"]
11
+
12
+ spec.summary = "onepage-scroll for rails"
13
+ spec.description = "onepage-scroll for rails"
14
+ spec.homepage = "https://github.com/enjoycreative/onepage_scroll_rails"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ # end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.10"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ end
data/release.sh ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/bash
2
+ bundle update
3
+ git add --all .
4
+ git commit -am "${*:1}"
5
+ git push
6
+ git push gh master
7
+ rake release
@@ -0,0 +1 @@
1
+ !function(e){var t={sectionContainer:"section",easing:"ease",animationTime:1e3,pagination:true,updateURL:false,keyboard:true,beforeMove:null,afterMove:null,loop:true,responsiveFallback:false,direction:"vertical"};e.fn.swipeEvents=function(){return this.each(function(){function i(e){var i=e.originalEvent.touches;if(i&&i.length){t=i[0].pageX;n=i[0].pageY;r.bind("touchmove",s)}}function s(e){var i=e.originalEvent.touches;if(i&&i.length){var o=t-i[0].pageX;var u=n-i[0].pageY;if(o>=50){r.trigger("swipeLeft")}if(o<=-50){r.trigger("swipeRight")}if(u>=50){r.trigger("swipeUp")}if(u<=-50){r.trigger("swipeDown")}if(Math.abs(o)>=50||Math.abs(u)>=50){r.unbind("touchmove",s)}}}var t,n,r=e(this);r.bind("touchstart",i)})};e.fn.onepage_scroll=function(n){function o(){var t=false;var n=typeof r.responsiveFallback;if(n=="number"){t=e(window).width()<r.responsiveFallback}if(n=="boolean"){t=r.responsiveFallback}if(n=="function"){valFunction=r.responsiveFallback();t=valFunction;typeOFv=typeof t;if(typeOFv=="number"){t=e(window).width()<valFunction}}if(t){e("body").addClass("disabled-onepage-scroll");e(document).unbind("mousewheel DOMMouseScroll MozMousePixelScroll");i.swipeEvents().unbind("swipeDown swipeUp")}else{if(e("body").hasClass("disabled-onepage-scroll")){e("body").removeClass("disabled-onepage-scroll");e("html, body, .wrapper").animate({scrollTop:0},"fast")}i.swipeEvents().bind("swipeDown",function(t){if(!e("body").hasClass("disabled-onepage-scroll"))t.preventDefault();i.moveUp()}).bind("swipeUp",function(t){if(!e("body").hasClass("disabled-onepage-scroll"))t.preventDefault();i.moveDown()});e(document).bind("mousewheel DOMMouseScroll MozMousePixelScroll",function(e){e.preventDefault();var t=e.originalEvent.wheelDelta||-e.originalEvent.detail;u(e,t)})}}function u(e,t){deltaOfInterest=t;var n=(new Date).getTime();if(n-lastAnimation<quietPeriod+r.animationTime){e.preventDefault();return}if(deltaOfInterest<0){i.moveDown()}else{i.moveUp()}lastAnimation=n}var r=e.extend({},t,n),i=e(this),s=e(r.sectionContainer);total=s.length,status="off",topPos=0,leftPos=0,lastAnimation=0,quietPeriod=500,paginationList="";e.fn.transformPage=function(t,n,r){if(typeof t.beforeMove=="function")t.beforeMove(r);if(e("html").hasClass("ie8")){if(t.direction=="horizontal"){var s=i.width()/100*n;e(this).animate({left:s+"px"},t.animationTime)}else{var s=i.height()/100*n;e(this).animate({top:s+"px"},t.animationTime)}}else{e(this).css({"-webkit-transform":t.direction=="horizontal"?"translate3d("+n+"%, 0, 0)":"translate3d(0, "+n+"%, 0)","-webkit-transition":"all "+t.animationTime+"ms "+t.easing,"-moz-transform":t.direction=="horizontal"?"translate3d("+n+"%, 0, 0)":"translate3d(0, "+n+"%, 0)","-moz-transition":"all "+t.animationTime+"ms "+t.easing,"-ms-transform":t.direction=="horizontal"?"translate3d("+n+"%, 0, 0)":"translate3d(0, "+n+"%, 0)","-ms-transition":"all "+t.animationTime+"ms "+t.easing,transform:t.direction=="horizontal"?"translate3d("+n+"%, 0, 0)":"translate3d(0, "+n+"%, 0)",transition:"all "+t.animationTime+"ms "+t.easing})}e(this).one("webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend",function(e){if(typeof t.afterMove=="function")t.afterMove(r)})};e.fn.moveDown=function(){var t=e(this);index=e(r.sectionContainer+".active").data("index");current=e(r.sectionContainer+"[data-index='"+index+"']");next=e(r.sectionContainer+"[data-index='"+(index+1)+"']");if(next.length<1){if(r.loop==true){pos=0;next=e(r.sectionContainer+"[data-index='1']")}else{return}}else{pos=index*100*-1}if(typeof r.beforeMove=="function")r.beforeMove(next.data("index"));current.removeClass("active");next.addClass("active");if(r.pagination==true){e(".onepage-pagination li a"+"[data-index='"+index+"']").removeClass("active");e(".onepage-pagination li a"+"[data-index='"+next.data("index")+"']").addClass("active")}e("body")[0].className=e("body")[0].className.replace(/\bviewing-page-\d.*?\b/g,"");e("body").addClass("viewing-page-"+next.data("index"));if(history.replaceState&&r.updateURL==true){var n=window.location.href.substr(0,window.location.href.indexOf("#"))+"#"+(index+1);history.pushState({},document.title,n)}t.transformPage(r,pos,next.data("index"))};e.fn.moveUp=function(){var t=e(this);index=e(r.sectionContainer+".active").data("index");current=e(r.sectionContainer+"[data-index='"+index+"']");next=e(r.sectionContainer+"[data-index='"+(index-1)+"']");if(next.length<1){if(r.loop==true){pos=(total-1)*100*-1;next=e(r.sectionContainer+"[data-index='"+total+"']")}else{return}}else{pos=(next.data("index")-1)*100*-1}if(typeof r.beforeMove=="function")r.beforeMove(next.data("index"));current.removeClass("active");next.addClass("active");if(r.pagination==true){e(".onepage-pagination li a"+"[data-index='"+index+"']").removeClass("active");e(".onepage-pagination li a"+"[data-index='"+next.data("index")+"']").addClass("active")}e("body")[0].className=e("body")[0].className.replace(/\bviewing-page-\d.*?\b/g,"");e("body").addClass("viewing-page-"+next.data("index"));if(history.replaceState&&r.updateURL==true){var n=window.location.href.substr(0,window.location.href.indexOf("#"))+"#"+(index-1);history.pushState({},document.title,n)}t.transformPage(r,pos,next.data("index"))};e.fn.moveTo=function(t){current=e(r.sectionContainer+".active");next=e(r.sectionContainer+"[data-index='"+t+"']");if(next.length>0){if(typeof r.beforeMove=="function")r.beforeMove(next.data("index"));current.removeClass("active");next.addClass("active");e(".onepage-pagination li a"+".active").removeClass("active");e(".onepage-pagination li a"+"[data-index='"+t+"']").addClass("active");e("body")[0].className=e("body")[0].className.replace(/\bviewing-page-\d.*?\b/g,"");e("body").addClass("viewing-page-"+next.data("index"));pos=(t-1)*100*-1;if(history.replaceState&&r.updateURL==true){var n=window.location.href.substr(0,window.location.href.indexOf("#"))+"#"+(t-1);history.pushState({},document.title,n)}i.transformPage(r,pos,t)}};i.addClass("onepage-wrapper").css("position","relative");e.each(s,function(t){e(this).css({position:"absolute",top:topPos+"%"}).addClass("section").attr("data-index",t+1);e(this).css({position:"absolute",left:r.direction=="horizontal"?leftPos+"%":0,top:r.direction=="vertical"||r.direction!="horizontal"?topPos+"%":0});if(r.direction=="horizontal")leftPos=leftPos+100;else topPos=topPos+100;if(r.pagination==true){paginationList+="<li><a data-index='"+(t+1)+"' href='#"+(t+1)+"'></a></li>"}});i.swipeEvents().bind("swipeDown",function(t){if(!e("body").hasClass("disabled-onepage-scroll"))t.preventDefault();i.moveUp()}).bind("swipeUp",function(t){if(!e("body").hasClass("disabled-onepage-scroll"))t.preventDefault();i.moveDown()});if(r.pagination==true){if(e("ul.onepage-pagination").length<1)e("<ul class='onepage-pagination'></ul>").prependTo("body");if(r.direction=="horizontal"){posLeft=i.find(".onepage-pagination").width()/2*-1;i.find(".onepage-pagination").css("margin-left",posLeft)}else{posTop=i.find(".onepage-pagination").height()/2*-1;i.find(".onepage-pagination").css("margin-top",posTop)}e("ul.onepage-pagination").html(paginationList)}if(window.location.hash!=""&&window.location.hash!="#1"){init_index=window.location.hash.replace("#","");if(parseInt(init_index)<=total&&parseInt(init_index)>0){e(r.sectionContainer+"[data-index='"+init_index+"']").addClass("active");e("body").addClass("viewing-page-"+init_index);if(r.pagination==true)e(".onepage-pagination li a"+"[data-index='"+init_index+"']").addClass("active");next=e(r.sectionContainer+"[data-index='"+init_index+"']");if(next){next.addClass("active");if(r.pagination==true)e(".onepage-pagination li a"+"[data-index='"+init_index+"']").addClass("active");e("body")[0].className=e("body")[0].className.replace(/\bviewing-page-\d.*?\b/g,"");e("body").addClass("viewing-page-"+next.data("index"));if(history.replaceState&&r.updateURL==true){var a=window.location.href.substr(0,window.location.href.indexOf("#"))+"#"+init_index;history.pushState({},document.title,a)}}pos=(init_index-1)*100*-1;i.transformPage(r,pos,init_index)}else{e(r.sectionContainer+"[data-index='1']").addClass("active");e("body").addClass("viewing-page-1");if(r.pagination==true)e(".onepage-pagination li a"+"[data-index='1']").addClass("active")}}else{e(r.sectionContainer+"[data-index='1']").addClass("active");e("body").addClass("viewing-page-1");if(r.pagination==true)e(".onepage-pagination li a"+"[data-index='1']").addClass("active")}if(r.pagination==true){e(".onepage-pagination li a").click(function(){var t=e(this).data("index");i.moveTo(t)})}e(document).bind("mousewheel DOMMouseScroll MozMousePixelScroll",function(t){t.preventDefault();var n=t.originalEvent.wheelDelta||-t.originalEvent.detail;if(!e("body").hasClass("disabled-onepage-scroll"))u(t,n)});if(r.responsiveFallback!=false){e(window).resize(function(){o()});o()}if(r.keyboard==true){e(document).keydown(function(t){var n=t.target.tagName.toLowerCase();if(!e("body").hasClass("disabled-onepage-scroll")){switch(t.which){case 38:if(n!="input"&&n!="textarea")i.moveUp();break;case 40:if(n!="input"&&n!="textarea")i.moveDown();break;case 32:if(n!="input"&&n!="textarea")i.moveDown();break;case 33:if(n!="input"&&n!="textarea")i.moveUp();break;case 34:if(n!="input"&&n!="textarea")i.moveDown();break;case 36:i.moveTo(1);break;case 35:i.moveTo(total);break;default:return}}})}return false}}(window.jQuery)
@@ -0,0 +1,428 @@
1
+ /* ===========================================================
2
+ * jquery-onepage-scroll.js v1.3.1
3
+ * ===========================================================
4
+ * Copyright 2013 Pete Rojwongsuriya.
5
+ * http://www.thepetedesign.com
6
+ *
7
+ * Create an Apple-like website that let user scroll
8
+ * one page at a time
9
+ *
10
+ * Credit: Eike Send for the awesome swipe event
11
+ * https://github.com/peachananr/onepage-scroll
12
+ *
13
+ * License: GPL v3
14
+ *
15
+ * ========================================================== */
16
+
17
+ ! function($) {
18
+
19
+ var defaults = {
20
+ sectionContainer: "section",
21
+ easing: "ease",
22
+ animationTime: 1000,
23
+ pagination: true,
24
+ updateURL: false,
25
+ keyboard: true,
26
+ beforeMove: null,
27
+ afterMove: null,
28
+ loop: true,
29
+ responsiveFallback: false,
30
+ direction: 'vertical'
31
+ };
32
+
33
+ /*------------------------------------------------*/
34
+ /* Credit: Eike Send for the awesome swipe event */
35
+ /*------------------------------------------------*/
36
+
37
+ $.fn.swipeEvents = function() {
38
+ return this.each(function() {
39
+
40
+ var startX,
41
+ startY,
42
+ $this = $(this);
43
+
44
+ $this.bind('touchstart', touchstart);
45
+
46
+ function touchstart(event) {
47
+ var touches = event.originalEvent.touches;
48
+ if (touches && touches.length) {
49
+ startX = touches[0].pageX;
50
+ startY = touches[0].pageY;
51
+ $this.bind('touchmove', touchmove);
52
+ }
53
+ }
54
+
55
+ function touchmove(event) {
56
+ var touches = event.originalEvent.touches;
57
+ if (touches && touches.length) {
58
+ var deltaX = startX - touches[0].pageX;
59
+ var deltaY = startY - touches[0].pageY;
60
+
61
+ if (deltaX >= 50) {
62
+ $this.trigger("swipeLeft");
63
+ }
64
+ if (deltaX <= -50) {
65
+ $this.trigger("swipeRight");
66
+ }
67
+ if (deltaY >= 50) {
68
+ $this.trigger("swipeUp");
69
+ }
70
+ if (deltaY <= -50) {
71
+ $this.trigger("swipeDown");
72
+ }
73
+ if (Math.abs(deltaX) >= 50 || Math.abs(deltaY) >= 50) {
74
+ $this.unbind('touchmove', touchmove);
75
+ }
76
+ }
77
+ }
78
+
79
+ });
80
+ };
81
+
82
+
83
+ $.fn.onepage_scroll = function(options) {
84
+ var settings = $.extend({}, defaults, options),
85
+ el = $(this),
86
+ sections = $(settings.sectionContainer)
87
+ total = sections.length,
88
+ status = "off",
89
+ topPos = 0,
90
+ leftPos = 0,
91
+ lastAnimation = 0,
92
+ quietPeriod = 500,
93
+ paginationList = "";
94
+
95
+ $.fn.transformPage = function(settings, pos, index) {
96
+ if (typeof settings.beforeMove == 'function') settings.beforeMove(index);
97
+
98
+ // Just a simple edit that makes use of modernizr to detect an IE8 browser and changes the transform method into
99
+ // an top animate so IE8 users can also use this script.
100
+ if ($('html').hasClass('ie8')) {
101
+ if (settings.direction == 'horizontal') {
102
+ var toppos = (el.width() / 100) * pos;
103
+ $(this).animate({
104
+ left: toppos + 'px'
105
+ }, settings.animationTime);
106
+ } else {
107
+ var toppos = (el.height() / 100) * pos;
108
+ $(this).animate({
109
+ top: toppos + 'px'
110
+ }, settings.animationTime);
111
+ }
112
+ } else {
113
+ $(this).css({
114
+ "-webkit-transform": (settings.direction == 'horizontal') ? "translate3d(" + pos + "%, 0, 0)" : "translate3d(0, " + pos + "%, 0)",
115
+ "-webkit-transition": "all " + settings.animationTime + "ms " + settings.easing,
116
+ "-moz-transform": (settings.direction == 'horizontal') ? "translate3d(" + pos + "%, 0, 0)" : "translate3d(0, " + pos + "%, 0)",
117
+ "-moz-transition": "all " + settings.animationTime + "ms " + settings.easing,
118
+ "-ms-transform": (settings.direction == 'horizontal') ? "translate3d(" + pos + "%, 0, 0)" : "translate3d(0, " + pos + "%, 0)",
119
+ "-ms-transition": "all " + settings.animationTime + "ms " + settings.easing,
120
+ "transform": (settings.direction == 'horizontal') ? "translate3d(" + pos + "%, 0, 0)" : "translate3d(0, " + pos + "%, 0)",
121
+ "transition": "all " + settings.animationTime + "ms " + settings.easing
122
+ });
123
+ }
124
+ $(this).one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(e) {
125
+ if (typeof settings.afterMove == 'function') settings.afterMove(index);
126
+ });
127
+ }
128
+
129
+ $.fn.moveDown = function() {
130
+ var el = $(this)
131
+ index = $(settings.sectionContainer + ".active").data("index");
132
+ current = $(settings.sectionContainer + "[data-index='" + index + "']");
133
+ next = $(settings.sectionContainer + "[data-index='" + (index + 1) + "']");
134
+ if (next.length < 1) {
135
+ if (settings.loop == true) {
136
+ pos = 0;
137
+ next = $(settings.sectionContainer + "[data-index='1']");
138
+ } else {
139
+ return
140
+ }
141
+
142
+ } else {
143
+ pos = (index * 100) * -1;
144
+ }
145
+ if (typeof settings.beforeMove == 'function') settings.beforeMove(next.data("index"));
146
+ current.removeClass("active")
147
+ next.addClass("active");
148
+ if (settings.pagination == true) {
149
+ $(".onepage-pagination li a" + "[data-index='" + index + "']").removeClass("active");
150
+ $(".onepage-pagination li a" + "[data-index='" + next.data("index") + "']").addClass("active");
151
+ }
152
+
153
+ $("body")[0].className = $("body")[0].className.replace(/\bviewing-page-\d.*?\b/g, '');
154
+ $("body").addClass("viewing-page-" + next.data("index"))
155
+
156
+ if (history.replaceState && settings.updateURL == true) {
157
+ var href = window.location.href.substr(0, window.location.href.indexOf('#')) + "#" + (index + 1);
158
+ history.pushState({}, document.title, href);
159
+ }
160
+ el.transformPage(settings, pos, next.data("index"));
161
+ }
162
+
163
+ $.fn.moveUp = function() {
164
+ var el = $(this)
165
+ index = $(settings.sectionContainer + ".active").data("index");
166
+ current = $(settings.sectionContainer + "[data-index='" + index + "']");
167
+ next = $(settings.sectionContainer + "[data-index='" + (index - 1) + "']");
168
+
169
+ if (next.length < 1) {
170
+ if (settings.loop == true) {
171
+ pos = ((total - 1) * 100) * -1;
172
+ next = $(settings.sectionContainer + "[data-index='" + total + "']");
173
+ } else {
174
+ return
175
+ }
176
+ } else {
177
+ pos = ((next.data("index") - 1) * 100) * -1;
178
+ }
179
+ if (typeof settings.beforeMove == 'function') settings.beforeMove(next.data("index"));
180
+ current.removeClass("active")
181
+ next.addClass("active")
182
+ if (settings.pagination == true) {
183
+ $(".onepage-pagination li a" + "[data-index='" + index + "']").removeClass("active");
184
+ $(".onepage-pagination li a" + "[data-index='" + next.data("index") + "']").addClass("active");
185
+ }
186
+ $("body")[0].className = $("body")[0].className.replace(/\bviewing-page-\d.*?\b/g, '');
187
+ $("body").addClass("viewing-page-" + next.data("index"))
188
+
189
+ if (history.replaceState && settings.updateURL == true) {
190
+ var href = window.location.href.substr(0, window.location.href.indexOf('#')) + "#" + (index - 1);
191
+ history.pushState({}, document.title, href);
192
+ }
193
+ el.transformPage(settings, pos, next.data("index"));
194
+ }
195
+
196
+ $.fn.moveTo = function(page_index) {
197
+ current = $(settings.sectionContainer + ".active")
198
+ next = $(settings.sectionContainer + "[data-index='" + (page_index) + "']");
199
+ if (next.length > 0) {
200
+ if (typeof settings.beforeMove == 'function') settings.beforeMove(next.data("index"));
201
+ current.removeClass("active")
202
+ next.addClass("active")
203
+ $(".onepage-pagination li a" + ".active").removeClass("active");
204
+ $(".onepage-pagination li a" + "[data-index='" + (page_index) + "']").addClass("active");
205
+ $("body")[0].className = $("body")[0].className.replace(/\bviewing-page-\d.*?\b/g, '');
206
+ $("body").addClass("viewing-page-" + next.data("index"))
207
+
208
+ pos = ((page_index - 1) * 100) * -1;
209
+
210
+ if (history.replaceState && settings.updateURL == true) {
211
+ var href = window.location.href.substr(0, window.location.href.indexOf('#')) + "#" + (page_index - 1);
212
+ history.pushState({}, document.title, href);
213
+ }
214
+ el.transformPage(settings, pos, page_index);
215
+ }
216
+ }
217
+
218
+ function responsive() {
219
+ //start modification
220
+ var valForTest = false;
221
+ var typeOfRF = typeof settings.responsiveFallback
222
+
223
+ if (typeOfRF == "number") {
224
+ valForTest = $(window).width() < settings.responsiveFallback;
225
+ }
226
+ if (typeOfRF == "boolean") {
227
+ valForTest = settings.responsiveFallback;
228
+ }
229
+ if (typeOfRF == "function") {
230
+ valFunction = settings.responsiveFallback();
231
+ valForTest = valFunction;
232
+ typeOFv = typeof valForTest;
233
+ if (typeOFv == "number") {
234
+ valForTest = $(window).width() < valFunction;
235
+ }
236
+ }
237
+
238
+ //end modification
239
+ if (valForTest) {
240
+ $("body").addClass("disabled-onepage-scroll");
241
+ $(document).unbind('mousewheel DOMMouseScroll MozMousePixelScroll');
242
+ el.swipeEvents().unbind("swipeDown swipeUp");
243
+ } else {
244
+ if ($("body").hasClass("disabled-onepage-scroll")) {
245
+ $("body").removeClass("disabled-onepage-scroll");
246
+ $("html, body, .wrapper").animate({
247
+ scrollTop: 0
248
+ }, "fast");
249
+ }
250
+
251
+
252
+ el.swipeEvents().bind("swipeDown", function(event) {
253
+ if (!$("body").hasClass("disabled-onepage-scroll")) event.preventDefault();
254
+ el.moveUp();
255
+ }).bind("swipeUp", function(event) {
256
+ if (!$("body").hasClass("disabled-onepage-scroll")) event.preventDefault();
257
+ el.moveDown();
258
+ });
259
+
260
+ $(document).bind('mousewheel DOMMouseScroll MozMousePixelScroll', function(event) {
261
+ event.preventDefault();
262
+ var delta = event.originalEvent.wheelDelta || -event.originalEvent.detail;
263
+ init_scroll(event, delta);
264
+ });
265
+ }
266
+ }
267
+
268
+
269
+ function init_scroll(event, delta) {
270
+ deltaOfInterest = delta;
271
+ var timeNow = new Date().getTime();
272
+ // Cancel scroll if currently animating or within quiet period
273
+ if (timeNow - lastAnimation < quietPeriod + settings.animationTime) {
274
+ event.preventDefault();
275
+ return;
276
+ }
277
+
278
+ if (deltaOfInterest < 0) {
279
+ el.moveDown()
280
+ } else {
281
+ el.moveUp()
282
+ }
283
+ lastAnimation = timeNow;
284
+ }
285
+
286
+ // Prepare everything before binding wheel scroll
287
+
288
+ el.addClass("onepage-wrapper").css("position", "relative");
289
+ $.each(sections, function(i) {
290
+ $(this).css({
291
+ position: "absolute",
292
+ top: topPos + "%"
293
+ }).addClass("section").attr("data-index", i + 1);
294
+
295
+
296
+ $(this).css({
297
+ position: "absolute",
298
+ left: (settings.direction == 'horizontal') ? leftPos + "%" : 0,
299
+ top: (settings.direction == 'vertical' || settings.direction != 'horizontal') ? topPos + "%" : 0
300
+ });
301
+
302
+ if (settings.direction == 'horizontal')
303
+ leftPos = leftPos + 100;
304
+ else
305
+ topPos = topPos + 100;
306
+
307
+
308
+ if (settings.pagination == true) {
309
+ paginationList += "<li><a data-index='" + (i + 1) + "' href='#" + (i + 1) + "'></a></li>"
310
+ }
311
+ });
312
+
313
+ el.swipeEvents().bind("swipeDown", function(event) {
314
+ if (!$("body").hasClass("disabled-onepage-scroll")) event.preventDefault();
315
+ el.moveUp();
316
+ }).bind("swipeUp", function(event) {
317
+ if (!$("body").hasClass("disabled-onepage-scroll")) event.preventDefault();
318
+ el.moveDown();
319
+ });
320
+
321
+ // Create Pagination and Display Them
322
+ if (settings.pagination == true) {
323
+ if ($('ul.onepage-pagination').length < 1) $("<ul class='onepage-pagination'></ul>").prependTo("body");
324
+
325
+ if (settings.direction == 'horizontal') {
326
+ posLeft = (el.find(".onepage-pagination").width() / 2) * -1;
327
+ el.find(".onepage-pagination").css("margin-left", posLeft);
328
+ } else {
329
+ posTop = (el.find(".onepage-pagination").height() / 2) * -1;
330
+ el.find(".onepage-pagination").css("margin-top", posTop);
331
+ }
332
+ $('ul.onepage-pagination').html(paginationList);
333
+ }
334
+
335
+ if (window.location.hash != "" && window.location.hash != "#1") {
336
+ init_index = window.location.hash.replace("#", "")
337
+
338
+ if (parseInt(init_index) <= total && parseInt(init_index) > 0) {
339
+ $(settings.sectionContainer + "[data-index='" + init_index + "']").addClass("active")
340
+ $("body").addClass("viewing-page-" + init_index)
341
+ if (settings.pagination == true) $(".onepage-pagination li a" + "[data-index='" + init_index + "']").addClass("active");
342
+
343
+ next = $(settings.sectionContainer + "[data-index='" + (init_index) + "']");
344
+ if (next) {
345
+ next.addClass("active")
346
+ if (settings.pagination == true) $(".onepage-pagination li a" + "[data-index='" + (init_index) + "']").addClass("active");
347
+ $("body")[0].className = $("body")[0].className.replace(/\bviewing-page-\d.*?\b/g, '');
348
+ $("body").addClass("viewing-page-" + next.data("index"))
349
+ if (history.replaceState && settings.updateURL == true) {
350
+ var href = window.location.href.substr(0, window.location.href.indexOf('#')) + "#" + (init_index);
351
+ history.pushState({}, document.title, href);
352
+ }
353
+ }
354
+ pos = ((init_index - 1) * 100) * -1;
355
+ el.transformPage(settings, pos, init_index);
356
+ } else {
357
+ $(settings.sectionContainer + "[data-index='1']").addClass("active")
358
+ $("body").addClass("viewing-page-1")
359
+ if (settings.pagination == true) $(".onepage-pagination li a" + "[data-index='1']").addClass("active");
360
+ }
361
+ } else {
362
+ $(settings.sectionContainer + "[data-index='1']").addClass("active")
363
+ $("body").addClass("viewing-page-1")
364
+ if (settings.pagination == true) $(".onepage-pagination li a" + "[data-index='1']").addClass("active");
365
+ }
366
+
367
+ if (settings.pagination == true) {
368
+ $(".onepage-pagination li a").click(function() {
369
+ var page_index = $(this).data("index");
370
+ el.moveTo(page_index);
371
+ });
372
+ }
373
+
374
+
375
+ $(document).bind('mousewheel DOMMouseScroll MozMousePixelScroll', function(event) {
376
+ event.preventDefault();
377
+ var delta = event.originalEvent.wheelDelta || -event.originalEvent.detail;
378
+ if (!$("body").hasClass("disabled-onepage-scroll")) init_scroll(event, delta);
379
+ });
380
+
381
+
382
+ if (settings.responsiveFallback != false) {
383
+ $(window).resize(function() {
384
+ responsive();
385
+ });
386
+
387
+ responsive();
388
+ }
389
+
390
+ if (settings.keyboard == true) {
391
+ $(document).keydown(function(e) {
392
+ var tag = e.target.tagName.toLowerCase();
393
+
394
+ if (!$("body").hasClass("disabled-onepage-scroll")) {
395
+ switch (e.which) {
396
+ case 38:
397
+ if (tag != 'input' && tag != 'textarea') el.moveUp()
398
+ break;
399
+ case 40:
400
+ if (tag != 'input' && tag != 'textarea') el.moveDown()
401
+ break;
402
+ case 32: //spacebar
403
+ if (tag != 'input' && tag != 'textarea') el.moveDown()
404
+ break;
405
+ case 33: //pageg up
406
+ if (tag != 'input' && tag != 'textarea') el.moveUp()
407
+ break;
408
+ case 34: //page dwn
409
+ if (tag != 'input' && tag != 'textarea') el.moveDown()
410
+ break;
411
+ case 36: //home
412
+ el.moveTo(1);
413
+ break;
414
+ case 35: //end
415
+ el.moveTo(total);
416
+ break;
417
+ default:
418
+ return;
419
+ }
420
+ }
421
+
422
+ });
423
+ }
424
+ return false;
425
+ }
426
+
427
+
428
+ }(window.jQuery);
@@ -0,0 +1,95 @@
1
+ body, html {
2
+ margin: 0;
3
+ overflow: hidden;
4
+ -webkit-transition: opacity 400ms;
5
+ -moz-transition: opacity 400ms;
6
+ transition: opacity 400ms;
7
+ }
8
+
9
+ body, .onepage-wrapper, html {
10
+ display: block;
11
+ position: static;
12
+ padding: 0;
13
+ width: 100%;
14
+ height: 100%;
15
+ }
16
+
17
+ .onepage-wrapper {
18
+ width: 100%;
19
+ height: 100%;
20
+ display: block;
21
+ position: relative;
22
+ padding: 0;
23
+ -webkit-transform-style: preserve-3d;
24
+ }
25
+
26
+ .onepage-wrapper .section {
27
+ width: 100%;
28
+ height: 100%;
29
+ }
30
+
31
+ .onepage-pagination {
32
+ position: absolute;
33
+ right: 10px;
34
+ top: 50%;
35
+ z-index: 5;
36
+ list-style: none;
37
+ margin: 0;
38
+ padding: 0;
39
+ }
40
+ .onepage-pagination li {
41
+ padding: 0;
42
+ text-align: center;
43
+ }
44
+ .onepage-pagination li a{
45
+ padding: 10px;
46
+ width: 4px;
47
+ height: 4px;
48
+ display: block;
49
+
50
+ }
51
+ .onepage-pagination li a:before{
52
+ content: '';
53
+ position: absolute;
54
+ width: 4px;
55
+ height: 4px;
56
+ background: rgba(0,0,0,0.85);
57
+ border-radius: 10px;
58
+ -webkit-border-radius: 10px;
59
+ -moz-border-radius: 10px;
60
+ }
61
+
62
+ .onepage-pagination li a.active:before{
63
+ width: 10px;
64
+ height: 10px;
65
+ background: none;
66
+ border: 1px solid black;
67
+ margin-top: -4px;
68
+ left: 8px;
69
+ }
70
+
71
+ .disabled-onepage-scroll, .disabled-onepage-scroll .wrapper {
72
+ overflow: auto;
73
+ }
74
+
75
+ .disabled-onepage-scroll .onepage-wrapper .section {
76
+ position: relative !important;
77
+ top: auto !important;
78
+ left: auto !important;
79
+ }
80
+ .disabled-onepage-scroll .onepage-wrapper {
81
+ -webkit-transform: none !important;
82
+ -moz-transform: none !important;
83
+ transform: none !important;
84
+ -ms-transform: none !important;
85
+ min-height: 100%;
86
+ }
87
+
88
+
89
+ .disabled-onepage-scroll .onepage-pagination {
90
+ display: none;
91
+ }
92
+
93
+ body.disabled-onepage-scroll, .disabled-onepage-scroll .onepage-wrapper, html {
94
+ position: inherit;
95
+ }
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: onepage_scroll_rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alexander Kiseliev
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-05-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: onepage-scroll for rails
42
+ email:
43
+ - dev@enjoycreative.ru
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".ruby-gemset"
50
+ - ".ruby-version"
51
+ - ".travis.yml"
52
+ - Gemfile
53
+ - LICENSE.txt
54
+ - README.md
55
+ - Rakefile
56
+ - bin/console
57
+ - bin/setup
58
+ - lib/onepage_scroll_rails.rb
59
+ - lib/onepage_scroll_rails/engine.rb
60
+ - lib/onepage_scroll_rails/version.rb
61
+ - onepage_scroll_rails.gemspec
62
+ - release.sh
63
+ - vendor/assets/javascripts/onepage-scroll/jquery.onepage-scroll.js
64
+ - vendor/assets/javascripts/onepage-scroll/jquery.onepage-scroll.min.js
65
+ - vendor/assets/stylesheets/onepage-scroll/onepage-scroll.css
66
+ homepage: https://github.com/enjoycreative/onepage_scroll_rails
67
+ licenses:
68
+ - MIT
69
+ metadata: {}
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 2.4.7
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: onepage-scroll for rails
90
+ test_files: []