summaryrefslogtreecommitdiffstats
path: root/js/cell.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/cell.js')
-rw-r--r--js/cell.js31
1 files changed, 14 insertions, 17 deletions
diff --git a/js/cell.js b/js/cell.js
index 1851a1d..9244eae 100644
--- a/js/cell.js
+++ b/js/cell.js
@@ -1,7 +1,7 @@
+// Flickity.Cell
( function( window, factory ) {
- 'use strict';
// universal module definition
-
+ /* jshint strict: false */
if ( typeof define == 'function' && define.amd ) {
// AMD
define( [
@@ -9,7 +9,7 @@
], function( getSize ) {
return factory( window, getSize );
});
- } else if ( typeof exports == 'object' ) {
+ } else if ( typeof module == 'object' && module.exports ) {
// CommonJS
module.exports = factory(
window,
@@ -35,42 +35,39 @@ function Cell( elem, parent ) {
this.create();
}
-var isIE8 = 'attachEvent' in window;
+var proto = Cell.prototype;
-Cell.prototype.create = function() {
+proto.create = function() {
this.element.style.position = 'absolute';
- // IE8 prevent child from changing focus http://stackoverflow.com/a/17525223/182183
- if ( isIE8 ) {
- this.element.setAttribute( 'unselectable', 'on' );
- }
this.x = 0;
this.shift = 0;
};
-Cell.prototype.destroy = function() {
+proto.destroy = function() {
// reset style
this.element.style.position = '';
var side = this.parent.originSide;
this.element.style[ side ] = '';
};
-Cell.prototype.getSize = function() {
+proto.getSize = function() {
this.size = getSize( this.element );
};
-Cell.prototype.setPosition = function( x ) {
+proto.setPosition = function( x ) {
this.x = x;
- this.setDefaultTarget();
+ this.updateTarget();
this.renderPosition( x );
};
-Cell.prototype.setDefaultTarget = function() {
+// setDefaultTarget v1 method, backwards compatibility, remove in v3
+proto.updateTarget = proto.setDefaultTarget = function() {
var marginProperty = this.parent.originSide == 'left' ? 'marginLeft' : 'marginRight';
this.target = this.x + this.size[ marginProperty ] +
this.size.width * this.parent.cellAlign;
};
-Cell.prototype.renderPosition = function( x ) {
+proto.renderPosition = function( x ) {
// render position of cell with in slider
var side = this.parent.originSide;
this.element.style[ side ] = this.parent.getPositionValue( x );
@@ -79,12 +76,12 @@ Cell.prototype.renderPosition = function( x ) {
/**
* @param {Integer} factor - 0, 1, or -1
**/
-Cell.prototype.wrapShift = function( shift ) {
+proto.wrapShift = function( shift ) {
this.shift = shift;
this.renderPosition( this.x + this.parent.slideableWidth * shift );
};
-Cell.prototype.remove = function() {
+proto.remove = function() {
this.element.parentNode.removeChild( this.element );
};