Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
"use strict";

// only adds async
const getSize = require("./get-size");

module.exports = Cell;

function Cell(elem, parent) {
  this.element = elem;
  this.parent = parent;
  this.create();
}

Cell.flickTheBean = Flickity => {
  Flickity.Cell = Cell;
};

var proto = Cell.prototype;

proto.create = function () {
  this.element.style.position = 'absolute';
  this.x = 0;
  this.shift = 0;
};

proto.destroy = function () {
  // reset style
  this.element.style.position = '';
  var side = this.parent.originSide;
  this.element.style[side] = '';
};

proto.getSize = function () {
  this.size = getSize(this.element);
};

proto.setPosition = function (x) {
  this.x = x;
  this.updateTarget();
  this.renderPosition(x);
}; // 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;
};

proto.renderPosition = function (x) {
  // render position of cell with in slider
  var side = this.parent.originSide;
  this.element.style[side] = this.parent.getPositionValue(x);
};
/**
 * @param {Integer} factor - 0, 1, or -1
 **/


proto.wrapShift = function (shift) {
  this.shift = shift;
  this.renderPosition(this.x + this.parent.slideableWidth * shift);
};

proto.remove = function () {
  this.element.parentNode.removeChild(this.element);
};