Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-scroll

Package Overview
Dependencies
Maintainers
1
Versions
118
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-scroll - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

README.md

202

lib/mixins/Helpers.js

@@ -9,7 +9,7 @@ "use strict";

var requestAnimationFrame = (function () {
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
function (callback, element, delay) {
window.setTimeout(callback, delay || (1000/60));
};
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
function (callback, element, delay) {
window.setTimeout(callback, delay || (1000/60));
};
})();

@@ -24,126 +24,124 @@

var currentPositionY = function() {
var supportPageOffset = window.pageXOffset !== undefined;
var isCSS1Compat = ((document.compatMode || "") === "CSS1Compat");
__currentPositionY = supportPageOffset ? window.pageYOffset : isCSS1Compat ?
document.documentElement.scrollTop : document.body.scrollTop;
return __currentPositionY;
var supportPageOffset = window.pageXOffset !== undefined;
var isCSS1Compat = ((document.compatMode || "") === "CSS1Compat");
__currentPositionY = supportPageOffset ? window.pageYOffset : isCSS1Compat ?
document.documentElement.scrollTop : document.body.scrollTop;
return __currentPositionY;
};
var setDirection = function() {
__direction = __targetPositionY > __currentPositionY ? "down" : "up";
__direction = __targetPositionY > __currentPositionY ? "down" : "up";
};
var animateTopScroll = function(y) {
switch(__direction) {
case "down":
__currentPositionY = __currentPositionY + __speed;
if(__currentPositionY >= __targetPositionY) {
console.log(__targetPositionY, __currentPositionY);
window.scrollTo(0, __targetPositionY);
return;
}
break;
case "up":
__currentPositionY = __currentPositionY - __speed;
if(__currentPositionY <= __targetPositionY) {
console.log(__targetPositionY, __currentPositionY);
window.scrollTo(0, __targetPositionY);
return;
}
break;
}
switch(__direction) {
case "down":
__currentPositionY = __currentPositionY + __speed;
if(__currentPositionY >= __targetPositionY) {
window.scrollTo(0, __targetPositionY);
return;
}
break;
case "up":
__currentPositionY = __currentPositionY - __speed;
if(__currentPositionY <= __targetPositionY) {
window.scrollTo(0, __targetPositionY);
return;
}
break;
}
window.scrollTo(0, __currentPositionY);
window.scrollTo(0, __currentPositionY);
requestAnimationFrame(animateTopScroll);
requestAnimationFrame(animateTopScroll);
};
var startAnimateTopScroll = function(y) {
__targetPositionY = y;
currentPositionY();
__targetPositionY = __targetPositionY + __currentPositionY
setDirection();
__targetPositionY = y;
currentPositionY();
__targetPositionY = __targetPositionY + __currentPositionY
setDirection();
requestAnimationFrame(animateTopScroll);
requestAnimationFrame(animateTopScroll);
};
var Helpers = {
Scroll: {
propTypes: {
to: React.PropTypes.string.isRequired
},
scrollTo : function(to) {
/*
* get the mapped DOM element
*/
Scroll: {
propTypes: {
to: React.PropTypes.string.isRequired
},
scrollTo : function(to) {
/*
* get the mapped DOM element
*/
var target = __mapped[to];
if(!target) {
throw new Error("target Element not found");
}
var target = __mapped[to];
if(!target) {
throw new Error("target Element not found");
}
var cordinates = target.getBoundingClientRect();
var cordinates = target.getBoundingClientRect();
/*
* if smooth is not provided just scroll into the view
*/
/*
* if smooth is not provided just scroll into the view
*/
if(!this.props.smooth) { /* Should look into browser compability for this one*/
window.scrollTo(0, cordinates.top);
return;
}
if(!this.props.smooth) { /* Should look into browser compability for this one*/
window.scrollTo(0, cordinates.top);
return;
}
/*
* Animate scrolling
*/
var options = {};
/*
* Animate scrolling
*/
var options = {};
startAnimateTopScroll(cordinates.top, options);
startAnimateTopScroll(cordinates.top, options);
},
onClick: function() {
/*
* give the posibility to override onClick
*/
if(this.props.onClick) {
this.props.onClick(event);
}
},
onClick: function() {
/*
* give the posibility to override onClick
*/
if(this.props.onClick) {
this.props.onClick(event);
}
/*
* dont bubble the navigation
*/
/*
* dont bubble the navigation
*/
if (event.stopPropagation) event.stopPropagation();
if (event.preventDefault) event.preventDefault();
if (event.stopPropagation) event.stopPropagation();
if (event.preventDefault) event.preventDefault();
/*
* do the magic!
*/
/*
* do the magic!
*/
this.scrollTo(this.props.to);
this.scrollTo(this.props.to);
},
componentDidMount: function() {
}
},
Element: {
propTypes: {
name: React.PropTypes.string.isRequired
},
componentDidMount: function() {
__mapped[this.props.name] = this.getDOMNode();
}
},
Spy: {
componentDidMount: function() {
}
}
},
componentDidMount: function() {
}
},
Element: {
propTypes: {
name: React.PropTypes.string.isRequired
},
componentDidMount: function() {
__mapped[this.props.name] = this.getDOMNode();
}
},
Spy: {
componentDidMount: function() {
}
}
};

@@ -150,0 +148,0 @@

{
"name": "react-scroll",
"version": "0.0.1",
"version": "0.1.0",
"description": "A scroll component for React.js",

@@ -5,0 +5,0 @@ "main": "lib",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc