Skip to content

Commit

Permalink
chore: build
Browse files Browse the repository at this point in the history
  • Loading branch information
jedrzejchalubek committed Nov 21, 2021
1 parent 3c3e627 commit a659d36
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 46 deletions.
72 changes: 57 additions & 15 deletions dist/glide.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -1772,7 +1772,7 @@ function Sizes (Glide, Components, Events) {
* @return {Number}
*/
get: function get() {
return Components.Html.root.offsetWidth;
return Components.Html.track.offsetWidth;
}
});
define(Sizes, 'wrapperSize', {
Expand Down Expand Up @@ -2452,7 +2452,12 @@ function Translate (Glide, Components, Events) {
*/
set: function set(value) {
var transform = mutator(Glide, Components).mutate(value);
Components.Html.wrapper.style.transform = "translate3d(".concat(-1 * transform, "px, 0px, 0px)");
var translate3d = "translate3d(".concat(-1 * transform, "px, 0px, 0px)");
Components.Html.wrapper.style.mozTransform = translate3d; // needed for supported Firefox 10-15

Components.Html.wrapper.style.webkitTransform = translate3d; // needed for supported Chrome 10-35, Safari 5.1-8, and Opera 15-22

Components.Html.wrapper.style.transform = translate3d;
},

/**
Expand Down Expand Up @@ -3077,8 +3082,6 @@ function Anchors (Glide, Components, Events) {
if (!detached) {
for (var i = 0; i < this.items.length; i++) {
this.items[i].draggable = false;
this.items[i].setAttribute('data-href', this.items[i].getAttribute('href'));
this.items[i].removeAttribute('href');
}

detached = true;
Expand All @@ -3098,7 +3101,6 @@ function Anchors (Glide, Components, Events) {
if (detached) {
for (var i = 0; i < this.items.length; i++) {
this.items[i].draggable = true;
this.items[i].setAttribute('href', this.items[i].getAttribute('data-href'));
}

detached = false;
Expand Down Expand Up @@ -3516,13 +3518,32 @@ function Autoplay (Glide, Components, Events) {
* @return {Void}
*/
mount: function mount() {
this.enable();
this.start();

if (Glide.settings.hoverpause) {
this.bind();
}
},

/**
* Enables autoplaying
*
* @returns {Void}
*/
enable: function enable() {
this._e = true;
},

/**
* Disables autoplaying.
*
* @returns {Void}
*/
disable: function disable() {
this._e = false;
},

/**
* Starts autoplaying in configured interval.
*
Expand All @@ -3532,6 +3553,12 @@ function Autoplay (Glide, Components, Events) {
start: function start() {
var _this = this;

if (!this._e) {
return;
}

this.enable();

if (Glide.settings.autoplay) {
if (isUndefined(this._i)) {
this._i = setInterval(function () {
Expand Down Expand Up @@ -3564,15 +3591,15 @@ function Autoplay (Glide, Components, Events) {
bind: function bind() {
var _this2 = this;

Binder.on('mouseenter', Components.Html.root, function () {
_this2.stop();

Events.emit('autoplay.enter');
Binder.on('mouseover', Components.Html.root, function () {
if (_this2._e) {
_this2.stop();
}
});
Binder.on('mouseleave', Components.Html.root, function () {
_this2.start();

Events.emit('autoplay.leave');
Binder.on('mouseout', Components.Html.root, function () {
if (_this2._e) {
_this2.start();
}
});
},

Expand Down Expand Up @@ -3620,7 +3647,11 @@ function Autoplay (Glide, Components, Events) {
* - on updating via API to reset interval that may changed
*/

Events.on(['run.before', 'pause', 'destroy', 'swipe.start', 'update'], function () {
Events.on(['run.before', 'swipe.start', 'update'], function () {
Autoplay.stop();
});
Events.on(['pause', 'destroy'], function () {
Autoplay.disable();
Autoplay.stop();
});
/**
Expand All @@ -3630,7 +3661,18 @@ function Autoplay (Glide, Components, Events) {
* - while ending a swipe
*/

Events.on(['run.after', 'play', 'swipe.end'], function () {
Events.on(['run.after', 'swipe.end'], function () {
Autoplay.start();
});
/**
* Start autoplaying:
* - after each run, to restart autoplaying
* - on playing via API
* - while ending a swipe
*/

Events.on(['play'], function () {
Autoplay.enable();
Autoplay.start();
});
/**
Expand Down
72 changes: 57 additions & 15 deletions dist/glide.js
Original file line number Diff line number Diff line change
Expand Up @@ -1778,7 +1778,7 @@
* @return {Number}
*/
get: function get() {
return Components.Html.root.offsetWidth;
return Components.Html.track.offsetWidth;
}
});
define(Sizes, 'wrapperSize', {
Expand Down Expand Up @@ -2458,7 +2458,12 @@
*/
set: function set(value) {
var transform = mutator(Glide, Components).mutate(value);
Components.Html.wrapper.style.transform = "translate3d(".concat(-1 * transform, "px, 0px, 0px)");
var translate3d = "translate3d(".concat(-1 * transform, "px, 0px, 0px)");
Components.Html.wrapper.style.mozTransform = translate3d; // needed for supported Firefox 10-15

Components.Html.wrapper.style.webkitTransform = translate3d; // needed for supported Chrome 10-35, Safari 5.1-8, and Opera 15-22

Components.Html.wrapper.style.transform = translate3d;
},

/**
Expand Down Expand Up @@ -3083,8 +3088,6 @@
if (!detached) {
for (var i = 0; i < this.items.length; i++) {
this.items[i].draggable = false;
this.items[i].setAttribute('data-href', this.items[i].getAttribute('href'));
this.items[i].removeAttribute('href');
}

detached = true;
Expand All @@ -3104,7 +3107,6 @@
if (detached) {
for (var i = 0; i < this.items.length; i++) {
this.items[i].draggable = true;
this.items[i].setAttribute('href', this.items[i].getAttribute('data-href'));
}

detached = false;
Expand Down Expand Up @@ -3522,13 +3524,32 @@
* @return {Void}
*/
mount: function mount() {
this.enable();
this.start();

if (Glide.settings.hoverpause) {
this.bind();
}
},

/**
* Enables autoplaying
*
* @returns {Void}
*/
enable: function enable() {
this._e = true;
},

/**
* Disables autoplaying.
*
* @returns {Void}
*/
disable: function disable() {
this._e = false;
},

/**
* Starts autoplaying in configured interval.
*
Expand All @@ -3538,6 +3559,12 @@
start: function start() {
var _this = this;

if (!this._e) {
return;
}

this.enable();

if (Glide.settings.autoplay) {
if (isUndefined(this._i)) {
this._i = setInterval(function () {
Expand Down Expand Up @@ -3570,15 +3597,15 @@
bind: function bind() {
var _this2 = this;

Binder.on('mouseenter', Components.Html.root, function () {
_this2.stop();

Events.emit('autoplay.enter');
Binder.on('mouseover', Components.Html.root, function () {
if (_this2._e) {
_this2.stop();
}
});
Binder.on('mouseleave', Components.Html.root, function () {
_this2.start();

Events.emit('autoplay.leave');
Binder.on('mouseout', Components.Html.root, function () {
if (_this2._e) {
_this2.start();
}
});
},

Expand Down Expand Up @@ -3626,7 +3653,11 @@
* - on updating via API to reset interval that may changed
*/

Events.on(['run.before', 'pause', 'destroy', 'swipe.start', 'update'], function () {
Events.on(['run.before', 'swipe.start', 'update'], function () {
Autoplay.stop();
});
Events.on(['pause', 'destroy'], function () {
Autoplay.disable();
Autoplay.stop();
});
/**
Expand All @@ -3636,7 +3667,18 @@
* - while ending a swipe
*/

Events.on(['run.after', 'play', 'swipe.end'], function () {
Events.on(['run.after', 'swipe.end'], function () {
Autoplay.start();
});
/**
* Start autoplaying:
* - after each run, to restart autoplaying
* - on playing via API
* - while ending a swipe
*/

Events.on(['play'], function () {
Autoplay.enable();
Autoplay.start();
});
/**
Expand Down
Loading

0 comments on commit a659d36

Please sign in to comment.