Skip to content

Commit

Permalink
update Unidragger 1.1.5; build v1.1.1
Browse files Browse the repository at this point in the history
track scrolling in pointerDown(); Fixes #123
dismiss pointerDown on range; Fixes #216

Fixes #189, fixes #201, 
Possibly resolves #122
  • Loading branch information
desandro committed Sep 1, 2015
1 parent a647d97 commit 3a24681
Show file tree
Hide file tree
Showing 13 changed files with 123 additions and 32 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ See [flickity.metafizzy.co](http://flickity.metafizzy.co) for complete docs and
Link directly to [Flickity files on cdnjs](https://cdnjs.com/libraries/flickity).

``` html
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/flickity/1.1.0/flickity.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/flickity/1.1.1/flickity.css">
<!-- or -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/flickity/1.1.0/flickity.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/flickity/1.1.1/flickity.min.css">
```

``` html
<script src="https://cdnjs.cloudflare.com/ajax/libs/flickity/1.1.0/flickity.pkgd.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/flickity/1.1.1/flickity.pkgd.js"></script>
<!-- or -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/flickity/1.1.0/flickity.pkgd.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/flickity/1.1.1/flickity.pkgd.min.js"></script>
```

### Package managers
Expand Down
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flickity",
"version": "1.1.0",
"version": "1.1.1",
"description": "Touch, responsive, flickable galleries",
"main": [
"js/index.js",
Expand All @@ -14,7 +14,7 @@
"get-style-property": "~1.0.4",
"doc-ready": "~1.0.4",
"classie": "~1.0.1",
"unidragger": "~1.1.2",
"unidragger": "~1.1.5",
"fizzy-ui-utils": "~1.0.0",
"tap-listener": "~1.1.1"
},
Expand Down
5 changes: 4 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
### v1.1.1

+ Fixed freeScroll bug flicking past ends. Fixed [#181](https://github.com/metafizzy/flickity/issues/181)
+ Fix regression with prepend animation. Fixed [#201](https://github.com/metafizzy/flickity/issues/201)
+ Fixed prepend animation regression. Fixed [#201](https://github.com/metafizzy/flickity/issues/201)
+ Allow range input sliding. Fixed [#216](https://github.com/metafizzy/flickity/issues/216)
+ Disable emulated click event triggering on iOS. Fixed bug with asNavFor on iOS [#189](https://github.com/metafizzy/flickity/issues/189)
+ Fixed staticClick triggering after scroll on touch devices. Fixed [#123](https://github.com/metafizzy/flickity/issues/123)

## v1.1.0

Expand Down
2 changes: 1 addition & 1 deletion css/flickity.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Flickity v1.1.0
/*! Flickity v1.1.1
http://flickity.metafizzy.co
---------------------------------------------- */

Expand Down
2 changes: 1 addition & 1 deletion dist/flickity.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Flickity v1.1.0
/*! Flickity v1.1.1
http://flickity.metafizzy.co
---------------------------------------------- */

Expand Down
2 changes: 1 addition & 1 deletion dist/flickity.min.css

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

106 changes: 91 additions & 15 deletions dist/flickity.pkgd.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Flickity PACKAGED v1.1.0
* Flickity PACKAGED v1.1.1
* Touch, responsive, flickable galleries
*
* Licensed GPLv3 for open source use
Expand Down Expand Up @@ -1910,7 +1910,7 @@ return proto;
}));

/*!
* Flickity v1.1.0
* Flickity v1.1.1
* Touch, responsive, flickable galleries
*
* Licensed GPLv3 for open source use
Expand Down Expand Up @@ -2978,7 +2978,7 @@ return Unipointer;
}));

/*!
* Unidragger v1.1.3
* Unidragger v1.1.5
* Draggable base class
* MIT license
*/
Expand Down Expand Up @@ -3118,6 +3118,14 @@ var disableImgOndragstart = !isIE8 ? noop : function( handle ) {
* @param {Event or Touch} pointer
*/
Unidragger.prototype.pointerDown = function( event, pointer ) {
// dismiss range sliders
if ( event.target.nodeName == 'INPUT' && event.target.type == 'range' ) {
// reset pointerDown logic
this.isPointerDown = false;
delete this.pointerIdentifier;
return;
}

this._dragPointerDown( event, pointer );
// kludge to blur focused inputs in dragger
var focused = document.activeElement;
Expand All @@ -3126,6 +3134,10 @@ Unidragger.prototype.pointerDown = function( event, pointer ) {
}
// bind move and end events
this._bindPostStartEvents( event );
// track scrolling
this.pointerDownScroll = Unidragger.getScrollPosition();
eventie.bind( window, 'scroll', this );

this.emitEvent( 'pointerDown', [ event, pointer ] );
};

Expand Down Expand Up @@ -3196,6 +3208,10 @@ Unidragger.prototype._dragPointerUp = function( event, pointer ) {
}
};

Unipointer.prototype.pointerDone = function() {
eventie.unbind( window, 'scroll', this );
};

// -------------------------- drag -------------------------- //

// dragStart
Expand Down Expand Up @@ -3244,6 +3260,11 @@ Unidragger.prototype.dragEnd = function( event, pointer ) {
this.emitEvent( 'dragEnd', [ event, pointer ] );
};

Unidragger.prototype.pointerDone = function() {
eventie.unbind( window, 'scroll', this );
delete this.pointerDownScroll;
};

// ----- onclick ----- //

// handle all clicks and prevent clicks when dragging
Expand All @@ -3257,19 +3278,46 @@ Unidragger.prototype.onclick = function( event ) {

// triggered after pointer down & up with no/tiny movement
Unidragger.prototype._staticClick = function( event, pointer ) {
// ignore emulated mouse up clicks
if ( this.isIgnoringMouseUp && event.type == 'mouseup' ) {
return;
}

// allow click in <input>s and <textarea>s
var nodeName = event.target.nodeName;
if ( nodeName == 'INPUT' || nodeName == 'TEXTAREA' ) {
event.target.focus();
}
this.staticClick( event, pointer );

// set flag for emulated clicks 300ms after touchend
if ( event.type != 'mouseup' ) {
this.isIgnoringMouseUp = true;
var _this = this;
// reset flag after 300ms
setTimeout( function() {
delete _this.isIgnoringMouseUp;
}, 400 );
}
};

Unidragger.prototype.staticClick = function( event, pointer ) {
this.emitEvent( 'staticClick', [ event, pointer ] );
};

// ----- ----- //
// ----- scroll ----- //

Unidragger.prototype.onscroll = function() {
var scroll = Unidragger.getScrollPosition();
var scrollMoveX = this.pointerDownScroll.x - scroll.x;
var scrollMoveY = this.pointerDownScroll.y - scroll.y;
// cancel click/tap if scroll is too much
if ( Math.abs( scrollMoveX ) > 3 || Math.abs( scrollMoveY ) > 3 ) {
this._pointerDone();
}
};

// ----- utils ----- //

Unidragger.getPointerPoint = function( pointer ) {
return {
Expand All @@ -3278,6 +3326,16 @@ Unidragger.getPointerPoint = function( pointer ) {
};
};

var isPageOffset = window.pageYOffset !== undefined;

// get scroll in { x, y }
Unidragger.getScrollPosition = function() {
return {
x: isPageOffset ? window.pageXOffset : document.body.scrollLeft,
y: isPageOffset ? window.pageYOffset : document.body.scrollTop
};
};

// ----- ----- //

Unidragger.getPointerPoint = Unipointer.getPointerPoint;
Expand Down Expand Up @@ -3391,6 +3449,14 @@ Flickity.prototype._childUIPointerDownDrag = function( event ) {
// -------------------------- pointer events -------------------------- //

Flickity.prototype.pointerDown = function( event, pointer ) {
// dismiss range sliders
if ( event.target.nodeName == 'INPUT' && event.target.type == 'range' ) {
// reset pointerDown logic
this.isPointerDown = false;
delete this.pointerIdentifier;
return;
}

this._dragPointerDown( event, pointer );

// kludge to blur focused inputs in dragger
Expand All @@ -3406,6 +3472,10 @@ Flickity.prototype.pointerDown = function( event, pointer ) {
classie.add( this.viewport, 'is-pointer-down' );
// bind move and end events
this._bindPostStartEvents( event );
// track scrolling
this.pointerDownScroll = Unidragger.getScrollPosition();
eventie.bind( window, 'scroll', this );

this.dispatchEvent( 'pointerDown', event, [ pointer ] );
};

Expand Down Expand Up @@ -3525,7 +3595,7 @@ Flickity.prototype.dragEnd = function( event, pointer ) {
// if free-scroll & not wrap around
// do not free-scroll if going outside of bounding cells
// so bounding cells can attract slider, and keep it in bounds
var restingX = this.getRestingDragPosition();
var restingX = this.getRestingPosition();
this.isFreeScrolling = -restingX > this.cells[0].target &&
-restingX < this.getLastCell().target;
} else if ( !this.options.freeScroll && index == this.selectedIndex ) {
Expand All @@ -3540,7 +3610,7 @@ Flickity.prototype.dragEnd = function( event, pointer ) {
};

Flickity.prototype.dragEndRestingSelect = function() {
var restingX = this.getRestingDragPosition();
var restingX = this.getRestingPosition();
// how far away from selected cell
var distance = Math.abs( this.getCellDistance( -restingX, this.selectedIndex ) );
// get closet resting going up and going down
Expand All @@ -3552,11 +3622,6 @@ Flickity.prototype.dragEndRestingSelect = function() {
return index;
};

Flickity.prototype.getRestingDragPosition = function() {
var dragVelocity = this.dragX - this.x;
return this.x + dragVelocity / ( 1 - this.getFrictionFactor() );
};

/**
* given resting X and distance to selected cell
* get the distance and index of the closest cell
Expand Down Expand Up @@ -4526,7 +4591,7 @@ Flickity.prototype._cellAddedRemoved = function( changedCellIndex, selectedIndex
this.selectedIndex = Math.max( 0, Math.min( this.cells.length - 1, this.selectedIndex ) );

this.emitEvent( 'cellAddedRemoved', [ changedCellIndex, selectedIndexDelta ] );
this.cellChange( changedCellIndex );
this.cellChange( changedCellIndex, true );
};

/**
Expand All @@ -4548,14 +4613,22 @@ Flickity.prototype.cellSizeChange = function( elem ) {
* logic any time a cell is changed: added, removed, or size changed
* @param {Integer} changedCellIndex - index of the changed cell, optional
*/
Flickity.prototype.cellChange = function( changedCellIndex ) {
Flickity.prototype.cellChange = function( changedCellIndex, isPositioningSlider ) {
var prevSlideableWidth = this.slideableWidth;
this._positionCells( changedCellIndex );
this._getWrapShiftCells();
this.setGallerySize();
// position slider
if ( this.options.freeScroll ) {
// shift x by change in slideableWidth
// TODO fix position shifts when prepending w/ freeScroll
this.x += prevSlideableWidth - this.slideableWidth;
this.positionSlider();
} else {
// do not position slider after lazy load
if ( isPositioningSlider ) {
this.positionSliderAtSelected();
}
this.select( this.selectedIndex );
}
};
Expand Down Expand Up @@ -4732,7 +4805,7 @@ return Flickity;
});

/*!
* Flickity asNavFor v1.0.1
* Flickity asNavFor v1.0.2
* enable asNavFor for Flickity
*/

Expand Down Expand Up @@ -5207,7 +5280,7 @@ function makeArray( obj ) {
});

/*!
* Flickity imagesLoaded v1.0.0
* Flickity imagesLoaded v1.0.1
* enables imagesLoaded option for Flickity
*/

Expand Down Expand Up @@ -5259,6 +5332,9 @@ Flickity.prototype.imagesLoaded = function() {
function onImagesLoadedProgress( instance, image ) {
var cell = _this.getParentCell( image.img );
_this.cellSizeChange( cell && cell.element );
if ( !_this.options.freeScroll ) {
_this.positionSliderAtSelected();
}
}
imagesLoaded( this.slider ).on( 'progress', onImagesLoadedProgress );
};
Expand Down
6 changes: 3 additions & 3 deletions dist/flickity.pkgd.min.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion js/add-remove-cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ Flickity.prototype.cellSizeChange = function( elem ) {
*/
Flickity.prototype.cellChange = function( changedCellIndex, isPositioningSlider ) {
var prevSlideableWidth = this.slideableWidth;
var prevX = this.x;
this._positionCells( changedCellIndex );
this._getWrapShiftCells();
this.setGallerySize();
Expand Down
12 changes: 12 additions & 0 deletions js/drag.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ Flickity.prototype._childUIPointerDownDrag = function( event ) {
// -------------------------- pointer events -------------------------- //

Flickity.prototype.pointerDown = function( event, pointer ) {
// dismiss range sliders
if ( event.target.nodeName == 'INPUT' && event.target.type == 'range' ) {
// reset pointerDown logic
this.isPointerDown = false;
delete this.pointerIdentifier;
return;
}

this._dragPointerDown( event, pointer );

// kludge to blur focused inputs in dragger
Expand All @@ -118,6 +126,10 @@ Flickity.prototype.pointerDown = function( event, pointer ) {
classie.add( this.viewport, 'is-pointer-down' );
// bind move and end events
this._bindPostStartEvents( event );
// track scrolling
this.pointerDownScroll = Unidragger.getScrollPosition();
eventie.bind( window, 'scroll', this );

this.dispatchEvent( 'pointerDown', event, [ pointer ] );
};

Expand Down
2 changes: 1 addition & 1 deletion js/flickity.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Flickity v1.1.0
* Flickity v1.1.1
* Touch, responsive, flickable galleries
*
* Licensed GPLv3 for open source use
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flickity",
"version": "1.1.0",
"version": "1.1.1",
"description": "Touch, responsive, flickable galleries",
"main": "js/index.js",
"style": "css/flickity.css",
Expand All @@ -12,7 +12,7 @@
"get-size": "~1.2.2",
"desandro-get-style-property": "~1.0.4",
"wolfy87-eventemitter": "~4.2.11",
"unidragger": "~1.1.2",
"unidragger": "~1.1.5",
"fizzy-ui-utils": "~1.0.0",
"tap-listener": "~1.1.1"
},
Expand Down
1 change: 1 addition & 0 deletions sandbox/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ <h1>basic1</h1>
<input type="checkbox" />
<input type="radio" name="foo" />
<input type="radio" name="foo" />
<input type="range" />
</p>
</div>
<div class="cell"></div>
Expand Down

0 comments on commit 3a24681

Please sign in to comment.