Skip to content

Commit

Permalink
remove jQuery usage and dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
GuyR committed Apr 1, 2016
1 parent 540fcf8 commit d4f40f7
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 56 deletions.
2 changes: 1 addition & 1 deletion dist/reactCustomScroll.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions example/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ require.config({
lodash: 'https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.10.1/lodash.min',
React: 'https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react-with-addons.min',
ReactDOM: 'https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react-dom.min',
jquery: 'https://code.jquery.com/jquery-2.1.4.min',
customScroll: '../dist/reactCustomScroll'
},
shim: {
lodash: {exports: '_'},
React: {exports: 'React'},
jquery: {exports: '$'}
React: {exports: 'React'}
},
map: {
'*': {
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
},
"homepage": "https://github.com/rommguy/react-custom-scroll#readme",
"dependencies": {
"jquery": "^2.2.0",
"lodash": "^3.10.1"
},
"devDependencies": {
Expand Down
17 changes: 8 additions & 9 deletions src/main/customScroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
var React = require('react');
var reactDOM = require('react-dom');
var _ = require('lodash');
var $ = require('jquery');
var template = require('./customScroll.rt.js');

function ensureWithinLimits(value, min, max) {
Expand Down Expand Up @@ -58,15 +57,15 @@ module.exports = React.createClass({
this.toggleScrollIfNeeded(contentHeight);

this.position = {
top: boundingRect.top + $(window).scrollTop(),
left: boundingRect.left + $(window).scrollLeft()
top: boundingRect.top + window.pageYOffset,
left: boundingRect.left + window.pageXOffset
};

this.freezePosition(prevProps);
},
componentWillUnmount: function () {
$(document).off('mousemove', this.onHandleDrag);
$(document).off('mouseup', this.onHandleDragEnd);
document.removeEventListener('mousemove', this.onHandleDrag);
document.removeEventListener('mouseup', this.onHandleDragEnd);
},
freezePosition: function (prevProps) {
var innerContainer = this.getScrolledElement();
Expand Down Expand Up @@ -156,8 +155,8 @@ module.exports = React.createClass({
this.setState({
onDrag: true
});
$(document).on('mousemove', this.onHandleDrag);
$(document).on('mouseup', this.onHandleDragEnd);
document.addEventListener('mousemove', this.onHandleDrag);
document.addEventListener('mouseup', this.onHandleDragEnd);
},
onHandleDrag: function (event) {
var mouseDeltaY = event.pageY - this.startDragMousePos;
Expand All @@ -169,8 +168,8 @@ module.exports = React.createClass({
this.setState({
onDrag: false
});
$(document).off('mousemove', this.onHandleDrag);
$(document).off('mouseup', this.onHandleDragEnd);
document.removeEventListener('mousemove', this.onHandleDrag);
document.removeEventListener('mouseup', this.onHandleDragEnd);
},
blockOuterScroll: function (e) {
if (this.props.allowOuterScroll) {
Expand Down
40 changes: 0 additions & 40 deletions src/test/test-main.js

This file was deleted.

3 changes: 1 addition & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ module.exports = {
externals: {
react: 'React',
'react-dom': 'ReactDOM',
lodash: 'lodash',
jquery: 'jquery'
lodash: 'lodash'
}
};

0 comments on commit d4f40f7

Please sign in to comment.