Reputation: 477
I've added some animation script to be used with the scrollorama plugin but it's causing parts of the wordpress admin not to function ie media button wont work, the error I get is TypeError: targetBlock is undefined in the scrollorama.js
$.scrollorama/scrollorama.animate()
jquery.scrollorama.js:285
<anonymous>
custom.js:100
m.Callbacks/j()
load-scripts.php:2
m.Callbacks/k.fireWith()
load-scripts.php:2
.ready()
load-scripts.php:2
J()
and also this in my custom.js file:
var scrollorama = $.scrollorama({ blocks:'.scrollblock' });
for(var i=1;i<7;i++){
var title = "#bubbles"+i;
switch(i){
case 1:
scrollorama.animate('.bubbles.a',{ duration: 2000, property:'top', start:1050, end:-windowh});
break;
}
}
Everything is working fine on the frontend but have just come across this issue, when I remove my custom.js file the admin works fine so I know it's this file that is the issue
Upvotes: 0
Views: 201
Reputation: 477
solved the issue: I didn't properly enque my scripts in the functions.php I had:
wp_enqueue_script( 'scrollorama', get_template_directory_uri() . '/js/jquery.scrollorama.js', array( 'jquery' ));
and it needed to be
add_action('wp_enqueue_scripts', 'load_javascript_files');
function load_javascript_files() {
wp_enqueue_script( 'scrollorama', get_template_directory_uri() . '/js/jquery.scrollorama.js', array( 'jquery' ));
}
Upvotes: 0