@@ -253,7 +253,7 @@ new Pjax({
|
|||||||
, switches: {
|
, switches: {
|
||||||
".js-Pjax": Pjax.switches.sideBySide
|
".js-Pjax": Pjax.switches.sideBySide
|
||||||
}
|
}
|
||||||
, switchesClasses: {
|
, switchesOptions: {
|
||||||
".js-Pjax": {
|
".js-Pjax": {
|
||||||
classNames: {
|
classNames: {
|
||||||
// class added on the element that will be removed
|
// class added on the element that will be removed
|
||||||
|
|||||||
12
src/pjax.js
12
src/pjax.js
@@ -499,7 +499,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
, sideBySide: function(oldEl, newEl, options, switchOptions) {
|
, sideBySide: function(oldEl, newEl, options, switchOptions) {
|
||||||
var elsToRemove = []
|
var forEach = Array.prototype.forEach
|
||||||
|
, elsToRemove = []
|
||||||
, elsToAdd = []
|
, elsToAdd = []
|
||||||
, fragToAppend = document.createDocumentFragment()
|
, fragToAppend = document.createDocumentFragment()
|
||||||
// height transition are shitty on safari
|
// height transition are shitty on safari
|
||||||
@@ -548,6 +549,8 @@
|
|||||||
// oldEl.parentNode.removeChild(newEl)
|
// oldEl.parentNode.removeChild(newEl)
|
||||||
// oldEl.style.height = oldEl.getBoundingClientRect().height + "px"
|
// oldEl.style.height = oldEl.getBoundingClientRect().height + "px"
|
||||||
|
|
||||||
|
switchOptions = switchOptions || {}
|
||||||
|
|
||||||
forEach.call(oldEl.childNodes, function(el) {
|
forEach.call(oldEl.childNodes, function(el) {
|
||||||
elsToRemove.push(el)
|
elsToRemove.push(el)
|
||||||
if (el.classList && !el.classList.contains("js-Pjax-remove")) {
|
if (el.classList && !el.classList.contains("js-Pjax-remove")) {
|
||||||
@@ -560,7 +563,9 @@
|
|||||||
if (switchOptions.callbacks && switchOptions.callbacks.removeElement) {
|
if (switchOptions.callbacks && switchOptions.callbacks.removeElement) {
|
||||||
switchOptions.callbacks.removeElement(el)
|
switchOptions.callbacks.removeElement(el)
|
||||||
}
|
}
|
||||||
|
if (switchOptions.classNames) {
|
||||||
el.className += " " + switchOptions.classNames.remove + " " + (options.backward ? switchOptions.classNames.backward : switchOptions.classNames.forward)
|
el.className += " " + switchOptions.classNames.remove + " " + (options.backward ? switchOptions.classNames.backward : switchOptions.classNames.forward)
|
||||||
|
}
|
||||||
animatedElsNumber++
|
animatedElsNumber++
|
||||||
Pjax.on(el, animationEventNames, sexyAnimationEnd, true)
|
Pjax.on(el, animationEventNames, sexyAnimationEnd, true)
|
||||||
}
|
}
|
||||||
@@ -568,7 +573,10 @@
|
|||||||
|
|
||||||
forEach.call(newEl.childNodes, function(el) {
|
forEach.call(newEl.childNodes, function(el) {
|
||||||
if (el.classList) {
|
if (el.classList) {
|
||||||
var addClasses = " js-Pjax-add " + switchOptions.classNames.add + " " + (options.backward ? switchOptions.classNames.forward : switchOptions.classNames.backward)
|
var addClasses = ""
|
||||||
|
if (switchOptions.classNames) {
|
||||||
|
addClasses = " js-Pjax-add " + switchOptions.classNames.add + " " + (options.backward ? switchOptions.classNames.forward : switchOptions.classNames.backward)
|
||||||
|
}
|
||||||
if (switchOptions.callbacks && switchOptions.callbacks.addElement) {
|
if (switchOptions.callbacks && switchOptions.callbacks.addElement) {
|
||||||
switchOptions.callbacks.addElement(el)
|
switchOptions.callbacks.addElement(el)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user