When trying to use switches I have to include the Require library in my HTML.
I then get constant file issues in node_modules.
Uncaught Error: Module name "events/on.js" has not been loaded yet for context: _. Use require([])
Just trying to add animation to the example in bower
Hi,
When trying to use switches I have to include the Require library in my HTML.
I then get constant file issues in node_modules.
`Uncaught Error: Module name "events/on.js" has not been loaded yet for context: _. Use require([])`
Just trying to add animation to the example in bower
require(['pjax'],function(pjax){alert('pjax loaded');varp=newpjax({selectors:["title",".js-Pjax"],switches:{".js-Pjax":require("pjax/lib/switches.js").sideBySide},switchesOptions:{".js-Pjax":{classNames:{// class added on the element that will be removed
remove:"Animated Animated--reverse Animate--fast Animate--noDelay",// class added on the element that will be added
add:"Animated",// class added on the element when it go backward
backward:"Animate--slideInRight",// class added on the element when it go forward (used for new page too)
forward:"Animate--slideInLeft"},callbacks:{// to make a nice transition with 2 pages as the same time
// we are playing with absolute positioning for element we are removing
// & we need live metrics to have something great
// see associated CSS below
removeElement:function(el){el.style.marginLeft="-"+(el.getBoundingClientRect().width/2)+"px"}}}}})});
if i add the brackets into the require switches.js call it then asks for it be done to every .js file in the lib folder
im loading the pjax.js withing a common.js file:
then calling:
```js
require(['pjax'], function(pjax){
alert('pjax loaded');
var p = new pjax({
selectors: ["title", ".js-Pjax"],
switches: {
".js-Pjax": require("pjax/lib/switches.js").sideBySide
},
switchesOptions: {
".js-Pjax": {
classNames: {
// class added on the element that will be removed
remove: "Animated Animated--reverse Animate--fast Animate--noDelay",
// class added on the element that will be added
add: "Animated",
// class added on the element when it go backward
backward: "Animate--slideInRight",
// class added on the element when it go forward (used for new page too)
forward: "Animate--slideInLeft"
},
callbacks: {
// to make a nice transition with 2 pages as the same time
// we are playing with absolute positioning for element we are removing
// & we need live metrics to have something great
// see associated CSS below
removeElement: function(el) {
el.style.marginLeft = "-" + (el.getBoundingClientRect().width/2) + "px"
}
}
}
}
})
});
```
if i add the brackets into the require switches.js call it then asks for it be done to every .js file in the lib folder
Thats fair enough. What is the recommended approach to loading? Do you just use commonjs on your website? I've tried the standalone js with nothing else and it still asks to me use require([]) on the switches.js require call.
Thats fair enough. What is the recommended approach to loading? Do you just use commonjs on your website? I've tried the standalone js with nothing else and it still asks to me use require([]) on the switches.js require call.
Even when trying to use something like the below in the example doesn't seem to work:
newPjax({selectors:["title",".js-Pjax"],switches:{".js-Pjax":require("pjax/lib/switches.js").sideBySide},switchesOptions:{".js-Pjax":{classNames:{// class added on the element that will be removed
remove:"Animated Animated--reverse Animate--fast Animate--noDelay",// class added on the element that will be added
add:"Animated",// class added on the element when it go backward
backward:"Animate--slideInRight",// class added on the element when it go forward (used for new page too)
forward:"Animate--slideInLeft"},callbacks:{// to make a nice transition with 2 pages as the same time
// we are playing with absolute positioning for element we are removing
// & we need live metrics to have something great
// see associated CSS below
removeElement:function(el){el.style.marginLeft="-"+(el.getBoundingClientRect().width/2)+"px"}}}}})
Just never loads the switches.js correctly
Even when trying to use something like the below in the example doesn't seem to work:
```js
new Pjax({
selectors: ["title", ".js-Pjax"],
switches: {
".js-Pjax": require("pjax/lib/switches.js").sideBySide
},
switchesOptions: {
".js-Pjax": {
classNames: {
// class added on the element that will be removed
remove: "Animated Animated--reverse Animate--fast Animate--noDelay",
// class added on the element that will be added
add: "Animated",
// class added on the element when it go backward
backward: "Animate--slideInRight",
// class added on the element when it go forward (used for new page too)
forward: "Animate--slideInLeft"
},
callbacks: {
// to make a nice transition with 2 pages as the same time
// we are playing with absolute positioning for element we are removing
// & we need live metrics to have something great
// see associated CSS below
removeElement: function(el) {
el.style.marginLeft = "-" + (el.getBoundingClientRect().width/2) + "px"
}
}
}
}
})
```
Just never loads the switches.js correctly
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Hi,
When trying to use switches I have to include the Require library in my HTML.
I then get constant file issues in node_modules.
Uncaught Error: Module name "events/on.js" has not been loaded yet for context: _. Use require([])Just trying to add animation to the example in bower
How are you consuming the module?
im loading the pjax.js withing a common.js file:
then calling:
if i add the brackets into the require switches.js call it then asks for it be done to every .js file in the lib folder
You are mixing amd with commonjs. This cannot work this way. Not sure how to handle this with amd.
Thats fair enough. What is the recommended approach to loading? Do you just use commonjs on your website? I've tried the standalone js with nothing else and it still asks to me use require([]) on the switches.js require call.
Even when trying to use something like the below in the example doesn't seem to work:
Just never loads the switches.js correctly
You should use browserify or webpack.
Note: use 3 backticks for code blocks