From 2b35057d94d351bbd832947c39eba5052c029152 Mon Sep 17 00:00:00 2001
From: Cyrus Cook <11858105+cyruscook@users.noreply.github.com>
Date: Thu, 2 May 2019 16:50:49 +0100
Subject: [PATCH 01/43] Added test.html
---
README.md | 4 ++--
test.html | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 2 deletions(-)
create mode 100644 test.html
diff --git a/README.md b/README.md
index 34b515e..eaf0ff3 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
-# [jQuery Scrollify](https://projects.lukehaas.me/scrollify)
+# [~~jQuery~~ Scrollify](https://projects.lukehaas.me/scrollify)
-A jQuery plugin that assists scrolling and snaps to sections. Touch optimised.
+A ~~jQuery~~ Pure JS plugin that assists scrolling and snaps to sections. Touch optimised.
## Demo
diff --git a/test.html b/test.html
new file mode 100644
index 0000000..45f3b58
--- /dev/null
+++ b/test.html
@@ -0,0 +1,34 @@
+
+
+
+
+
+ It's pretty cool isn't it
+
+
+
+
+
+
+
+
\ No newline at end of file
From d96122b74213cb8d1b3ad024ffb5ae3111e4019f Mon Sep 17 00:00:00 2001
From: Cyrus Cook <11858105+cyruscook@users.noreply.github.com>
Date: Thu, 2 May 2019 16:52:07 +0100
Subject: [PATCH 02/43] NO JQUERY
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index eaf0ff3..7ca1fab 100644
--- a/README.md
+++ b/README.md
@@ -22,7 +22,7 @@ A ~~jQuery~~ Pure JS plugin that assists scrolling and snaps to sections. Touch
## Basic setup
-Scrollify requires jQuery 1.7+.
+Scrollify requires ~~jQuery 1.7+~~ absolutely nothing.
The most basic setup is as follows:
@@ -153,7 +153,7 @@ The update method recalculates the heights and positions of the panels.
`$.scrollify.current()`
-The current method returns the current section as a jQuery object.
+The current method returns the current section as a DOM object.
`$.scrollify.currentIndex()`
From 6375339246366b994960ec92ab7af17a1dc5bd9a Mon Sep 17 00:00:00 2001
From: Cyrus Cook <11858105+cyruscook@users.noreply.github.com>
Date: Thu, 2 May 2019 17:17:17 +0100
Subject: [PATCH 03/43] Removed jquery dependencies
---
jquery.scrollify.js | 853 ------------------------
scrollify.js | 851 +++++++++++++++++++++++
scrollify.jquery.json => scrollify.json | 5 +-
test.html | 11 +-
4 files changed, 862 insertions(+), 858 deletions(-)
delete mode 100644 jquery.scrollify.js
create mode 100644 scrollify.js
rename scrollify.jquery.json => scrollify.json (87%)
diff --git a/jquery.scrollify.js b/jquery.scrollify.js
deleted file mode 100644
index f7210a7..0000000
--- a/jquery.scrollify.js
+++ /dev/null
@@ -1,853 +0,0 @@
-/*!
- * jQuery Scrollify
- * Version 1.0.20
- *
- * Requires:
- * - jQuery 1.7 or higher
- *
- * https://github.com/lukehaas/Scrollify
- *
- * Copyright 2016, Luke Haas
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and associated documentation files (the "Software"), to deal in
- * the Software without restriction, including without limitation the rights to
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
- * the Software, and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-
-
-if touchScroll is false - update index
-
- */
-(function (global,factory) {
- "use strict";
- if (typeof define === 'function' && define.amd) {
- // AMD. Register as an anonymous module.
- define(['jquery'], function($) {
- return factory($, global, global.document);
- });
- } else if (typeof module === 'object' && module.exports) {
- // Node/CommonJS
- module.exports = factory(require('jquery'), global, global.document);
- } else {
- // Browser globals
- factory(jQuery, global, global.document);
- }
-}(typeof window !== 'undefined' ? window : this, function ($, window, document, undefined) {
- "use strict";
- var heights = [],
- names = [],
- elements = [],
- overflow = [],
- index = 0,
- currentIndex = 0,
- interstitialIndex = 1,
- hasLocation = false,
- timeoutId,
- timeoutId2,
- $window = $(window),
- portHeight,
- top = $window.scrollTop(),
- scrollable = false,
- locked = false,
- scrolled = false,
- manualScroll,
- swipeScroll,
- util,
- disabled = false,
- scrollSamples = [],
- scrollTime = new Date().getTime(),
- firstLoad = true,
- initialised = false,
- destination = 0,
- wheelEvent = 'onwheel' in document ? 'wheel' : document.onmousewheel !== undefined ? 'mousewheel' : 'DOMMouseScroll',
- settings = {
- //section should be an identifier that is the same for each section
- section: ".section",
- sectionName: "section-name",
- interstitialSection: "",
- easing: "easeOutExpo",
- scrollSpeed: 1100,
- offset: 0,
- scrollbars: true,
- target:"html,body",
- standardScrollElements: false,
- setHeights: true,
- overflowScroll:true,
- updateHash: true,
- touchScroll:true,
- before:function() {},
- after:function() {},
- afterResize:function() {},
- afterRender:function() {}
- };
- function getportHeight() {
- return ($window.height() + settings.offset);
- }
- function animateScroll(index,instant,callbacks,toTop) {
- if(currentIndex===index) {
- callbacks = false;
- }
- if(disabled===true) {
- return true;
- }
- if(names[index]) {
- scrollable = false;
- if(firstLoad===true) {
- firstLoad = false;
- settings.afterRender();
- }
- if(callbacks) {
- if( typeof settings.before == 'function' && settings.before(index,elements) === false ){
- return true;
- }
- }
- interstitialIndex = 1;
- destination = (!index) ? 0 : heights[index];
- if(firstLoad===false && currentIndex>index && toTop===false) {
- //We're going backwards
- if(overflow[index]) {
- portHeight = getportHeight();
-
- interstitialIndex = parseInt(elements[index].outerHeight()/portHeight);
-
- destination = parseInt(heights[index])+(elements[index].outerHeight()-portHeight);
- }
- }
-
-
- if(settings.updateHash && settings.sectionName && !(firstLoad===true && index===0)) {
- if(history.pushState) {
- try {
- history.replaceState(null, null, names[index]);
- } catch (e) {
- if(window.console) {
- console.warn("Scrollify warning: Page must be hosted to manipulate the hash value.");
- }
- }
-
- } else {
- window.location.hash = names[index];
- }
- }
-
- currentIndex = index;
- if(instant) {
- $(settings.target).stop().scrollTop(destination);
- if(callbacks) {
- settings.after(index,elements);
- }
- } else {
- locked = true;
- if( $().velocity ) {
- $(settings.target).stop().velocity('scroll', {
- duration: settings.scrollSpeed,
- easing: settings.easing,
- offset: destination,
- mobileHA: false
- });
- } else {
- $(settings.target).stop().animate({
- scrollTop: destination
- }, settings.scrollSpeed,settings.easing);
- }
-
- if(window.location.hash.length && settings.sectionName && window.console) {
- try {
- if($(window.location.hash).length) {
- console.warn("Scrollify warning: ID matches hash value - this will cause the page to anchor.");
- }
- } catch (e) {}
- }
- $(settings.target).promise().done(function(){
- locked = false;
- firstLoad = false;
- if(callbacks) {
- settings.after(index,elements);
- }
- });
- }
-
- }
- }
-
- function isAccelerating(samples) {
- function average(num) {
- var sum = 0;
-
- var lastElements = samples.slice(Math.max(samples.length - num, 1));
-
- for(var i = 0; i < lastElements.length; i++){
- sum += lastElements[i];
- }
-
- return Math.ceil(sum/num);
- }
-
- var avEnd = average(10);
- var avMiddle = average(70);
-
- if(avEnd >= avMiddle) {
- return true;
- } else {
- return false;
- }
- }
- var scrollify = function(options) {
- initialised = true;
- $.easing['easeOutExpo'] = function(x, t, b, c, d) {
- return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
- };
-
- manualScroll = {
- handleMousedown:function() {
- if(disabled===true) {
- return true;
- }
- scrollable = false;
- scrolled = false;
- },
- handleMouseup:function() {
- if(disabled===true) {
- return true;
- }
- scrollable = true;
- if(scrolled) {
- //instant,callbacks
- manualScroll.calculateNearest(false,true);
- }
- },
- handleScroll:function() {
- if(disabled===true) {
- return true;
- }
- if(timeoutId){
- clearTimeout(timeoutId);
- }
-
- timeoutId = setTimeout(function(){
- scrolled = true;
- if(scrollable===false) {
- return false;
- }
- scrollable = false;
- //instant,callbacks
- manualScroll.calculateNearest(false,true);
- }, 200);
- },
- calculateNearest:function(instant,callbacks) {
- top = $window.scrollTop();
- var i =1,
- max = heights.length,
- closest = 0,
- prev = Math.abs(heights[0] - top),
- diff;
- for(;i