Skip to content

Commit

Permalink
Wheel: Use native scroll event instead of external dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
nir9 committed Apr 12, 2023
1 parent 349ee7c commit 978f0d9
Show file tree
Hide file tree
Showing 14 changed files with 12 additions and 168 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ A simple & beautiful touch carousel
![ItemSlide](https://raw.github.com/nir9/itemslide/master/website-src/img/image.jpg)


#### Optional Plugins (To add features)
- [jQuery Mousewheel (Adds scrolling) (~2.5KB)](https://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.13/jquery.mousewheel.js)



### Downloading

#### [Download](https://itemslide.org/dist/itemslide.min.js)
Expand Down
2 changes: 1 addition & 1 deletion dist/itemslide.min.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

<title>ItemSlide.js - Documentation</title>

<link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400,600' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
<link href="../website-src/layout.css" rel="stylesheet" />
<link href="layout.css" rel="stylesheet" />
Expand Down
2 changes: 0 additions & 2 deletions examples/buttons_carousel/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<script src="../../dist/itemslide.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js"></script>

<!--Scripts--->
<script src="sliding.js"></script>

</head>
Expand Down
1 change: 0 additions & 1 deletion examples/fullscreen_navigation/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@


<script src="../../dist/itemslide.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js"></script>

<script src="sliding.js"></script>

Expand Down
1 change: 0 additions & 1 deletion examples/left_carousel/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<script src="../../dist/itemslide.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js"></script>

<!--Scripts--->
<script src="sliding.js"></script>
Expand Down
66 changes: 0 additions & 66 deletions examples/simple_carousel/index.html

This file was deleted.

64 changes: 0 additions & 64 deletions examples/simple_carousel/main.css

This file was deleted.

13 changes: 0 additions & 13 deletions examples/simple_carousel/sliding.js

This file was deleted.

1 change: 0 additions & 1 deletion examples/two_carousels/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<script src="../../dist/itemslide.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js"></script>

<!--Scripts--->
<script src="sliding.js"></script>
Expand Down
3 changes: 0 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@

<title>ItemSlide.js - JavaScript touch carousel</title>

<link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400,600' rel='stylesheet' type='text/css'>

<link href="website-src/layout.css" rel="stylesheet" />
<link href="website-src/sliding.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.13/jquery.mousewheel.js"></script>

<script src="dist/itemslide.min.js"></script>
<script src="website-src/sliding.js"></script>
Expand Down
18 changes: 10 additions & 8 deletions src/mousewheel.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
// Add mousewheel capability to carousel
// IF YOU WANT TO ADD MOUSEWHEEL CAPABILITY - USE: https://github.com/jquery/jquery-mousewheel

module.exports = {
add: function (_this, anim, nav, slides) {
// Add a mousewheel listener to carousel
var touchCounter = 0,
sensetivity = 4; // Less is more (for the touchpad)

slides.mousewheel(function (e) {
slides.on("wheel", function (e) {

// Check if vertical pan is occuring... (if occuring dont continue)
if (!nav.get_vertical_pan()) {
var deltaY = e.originalEvent.deltaY;
var deltaX = e.originalEvent.deltaX;
var delta = e.originalEvent.wheelDelta;

var isWheel = (e.deltaFactor >= 100 || e.deltaFactor % 1 == 0); // Checked on Chrome, Firefox and Edge
var isWheel = (delta >= 100 || e.delta % 1 == 0);

if (!isWheel) {
// different behavior for touchpad...
Expand All @@ -25,11 +26,12 @@ module.exports = {


e.preventDefault();
//Outer sorthand-if is for it to goto next or prev. the inner for touchpad.
var mouseLandingIndex = _this.vars.currentIndex - (((e.deltaX == 0 ? e.deltaY : e.deltaX) > 0) ? 1 : -1);
// Outer sorthand-if is for it to goto next or prev. the inner for touchpad.
var mouseLandingIndex = _this.vars.currentIndex - (((deltaX == 0 ? deltaY : deltaX) > 0) ? -1 : 1);

if (mouseLandingIndex >= slides.children('li').length || mouseLandingIndex < 0) //If exceeds boundaries dont goto slide
if (mouseLandingIndex >= slides.children('li').length || mouseLandingIndex < 0) { // If exceeds boundaries dont goto slide
return; //Consider in gotoSlide
}

_this.vars.velocity = 0; //No BOUNCE

Expand Down
1 change: 0 additions & 1 deletion website-src/download.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

<title>ItemSlide.js - Download</title>

<link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400,600' rel='stylesheet' type='text/css'>
<link href="layout.css" rel="stylesheet" />
<link href="download.css" rel="stylesheet" />
</head>
Expand Down
2 changes: 1 addition & 1 deletion website-src/layout.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
body {
font-family: 'Source Sans Pro', sans-serif;
font-family: calibri, sans-serif;
text-align: center;
margin: 0;
}
Expand Down

0 comments on commit 978f0d9

Please sign in to comment.