react-img-carousel
Advanced tools
Comparing version 1.2.4 to 1.2.5
@@ -556,2 +556,3 @@ 'use strict'; | ||
onMouseLeave: this.onMouseLeave, | ||
onMouseOver: this.onMouseOver, | ||
onMouseEnter: this.onMouseEnter, | ||
@@ -904,2 +905,12 @@ onTouchStart: this.onTouchStart | ||
value: function onMouseEnter() { | ||
document.addEventListener('mousemove', this.handleMovement, false); | ||
} | ||
/** | ||
* Invoked when the mouse cursor moves around a slide. | ||
*/ | ||
}, { | ||
key: 'handleMovement', | ||
value: function handleMovement() { | ||
this.setHoverState(true); | ||
@@ -909,2 +920,12 @@ } | ||
/** | ||
* Invoked when the mouse cursor moves over a slide. | ||
*/ | ||
}, { | ||
key: 'onMouseOver', | ||
value: function onMouseOver() { | ||
this.setHoverState(true); | ||
} | ||
/** | ||
* Keeps track of the current hover state. | ||
@@ -947,2 +968,3 @@ * | ||
value: function onMouseLeave() { | ||
document.removeEventListener('mousemove', this.handleMovement, false); | ||
this.setHoverState(false); | ||
@@ -949,0 +971,0 @@ !this._animating && this.stopDragging(); |
{ | ||
"name": "react-img-carousel", | ||
"version": "1.2.4", | ||
"version": "1.2.5", | ||
"description": "Provides an image carousel React component.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -413,2 +413,3 @@ import React, { PropTypes, Component, Children, cloneElement } from 'react'; | ||
onMouseLeave={ this.onMouseLeave } | ||
onMouseOver={ this.onMouseOver } | ||
onMouseEnter={ this.onMouseEnter } | ||
@@ -726,2 +727,9 @@ onTouchStart={ this.onTouchStart } | ||
onMouseEnter () { | ||
document.addEventListener('mousemove', this.handleMovement, false); | ||
} | ||
/** | ||
* Invoked when the mouse cursor moves around a slide. | ||
*/ | ||
handleMovement () { | ||
this.setHoverState(true); | ||
@@ -731,2 +739,9 @@ } | ||
/** | ||
* Invoked when the mouse cursor moves over a slide. | ||
*/ | ||
onMouseOver () { | ||
this.setHoverState(true); | ||
} | ||
/** | ||
* Keeps track of the current hover state. | ||
@@ -758,2 +773,3 @@ * | ||
onMouseLeave () { | ||
document.removeEventListener('mousemove', this.handleMovement, false); | ||
this.setHoverState(false); | ||
@@ -760,0 +776,0 @@ !this._animating && this.stopDragging(); |
@@ -21,3 +21,2 @@ import React from 'react'; | ||
describe('Carousel', () => { | ||
beforeEach(() => { | ||
@@ -218,2 +217,22 @@ imagesFetched = []; | ||
it('should pause when mouse is moving', done => { | ||
const carousel = renderToJsdom( | ||
<Carousel slideWidth='300px' viewportWidth='300px' infinite={ false } autoplay={ true } pauseOnHover={ true }> | ||
<div id='slide1' /> | ||
<div id='slide2' /> | ||
<div id='slide3' /> | ||
</Carousel> | ||
); | ||
setImmediate(() => { | ||
const track = document.querySelector('.carousel-viewport'); | ||
const setHoverState = (bool) => { | ||
expect(bool).to.be.true; | ||
done(); | ||
}; | ||
carousel.setHoverState = setHoverState; | ||
carousel.handleMovement(track); | ||
}); | ||
}); | ||
it('should navigate to the last slide when a right swipe event occurs on the first slide', done => { | ||
@@ -220,0 +239,0 @@ const carousel = renderToJsdom( |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
106045
2565