javascript - Including waypoints in wordpress -


so i'm trying include waypoints.js in wordpress page can't figure out why not working.

i got in functions.php inside theme (and put noframework.waypoints.min.js inside js folder):

function waypoints_init() {     wp_enqueue_script( 'waypointsjs', get_template_directory_uri() . '/js/noframework.waypoints.min.js', array('jquery'), true); } add_action('wp_enqueue_scripts', 'waypoints_init'); 

then wrote:

function waypointtrigger() { echo '<script>     jquery(document).ready(function() {         var waypoint = new waypoint({           element: document.getelementbyid("triggerpointid"),           handler: function() {             alert("basic waypoint triggered");           }         });     }) </script>'; } add_action('wp_footer', 'waypointtrigger'); 

and still when scroll down point element id mentioned above located nothing @ all.

where did make mistake?

i ended adding functions.php

//*waypoints function waypoints_init() {     wp_enqueue_script( 'waypointsjs', get_template_directory_uri() . '/js/jquery.waypoints.js', array('jquery'), true); } add_action('wp_enqueue_scripts', 'waypoints_init'); 

then added custom .js file set jquery needed website (including waypoints):

function yourcustomjsfunction() { wp_enqueue_script( 'type_anything_here', get_template_directory_uri() . '/js/yourcustomjs.js', array('jquery') ); } add_action('wp_enqueue_scripts', 'yourcustomjsfunction'); 

then remember add every single line of code in:

jquery(function($){     //here can use normal jquery syntax example:      var mainscreenheight = $('#start').height();      $(window).on('scroll', function() {             var st = $(this).scrolltop();             if (st <= mainscreenheight) {                 $('#custombox').css({'opacity' : (0 + st / mainscreenheight) });             };     }); }); 

hope helps!


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -