- This topic has 17 replies, 3 voices, and was last updated 5 years, 10 months ago by David.
-
AuthorPosts
-
June 18, 2018 at 8:03 am #602765David
Hello
I’m trying to get the page header to move slightly on rollover like this…
https://codepen.io/onurburak9/pen/oxKMQq
I’ve added the javascript via the GP hooks but can’t get it to work.
Can someone please help with this?
This is the website…
Thanks
DaveJune 18, 2018 at 1:36 pm #602996LeoStaffCustomer SupportHi there,
Where are you adding the hooks?
Have you added the CSS as well? Don’t think I’m seeing them.
Let me know.
June 19, 2018 at 12:25 am #603247DavidHook for the javascript is in wp-head.
I’ve added this to the child theme css…
.generate-content-header {
background-size: calc(100% + 50px);
}June 19, 2018 at 4:37 am #603407DavidStaffCustomer SupportHi there, try targeting the ID of the pageheader in your script, in the link provided it is:
#page-header-21
June 19, 2018 at 4:50 am #603414DavidHi David
I’ve tried this but the movement i’snt showing.
Any other ideas??
Thanks
DaveJune 19, 2018 at 4:58 am #603416DavidStaffCustomer SupportHi David, ok so first off try replacing all
$
instances withjQuery
– and if still an issue move the code to wp_footJune 19, 2018 at 5:13 am #603426DavidI’ve moved this to wp_footer, but still not working…
<script type=”text/javascript”>
jQuery(document).ready(function() {
var movementStrength = 25;
var height = movementStrength / jQuery(window).height();
var width = movementStrength / jQuery(window).width();
jQuery(“.top-image”).mousemove(function(e){
var pageX = e.pageX – (jQuery(window).width() / 2);
var pageY = e.pageY – (jQuery(window).height() / 2);
var newvalueX = width * pageX * -1 – 25;
var newvalueY = height * pageY * -1 – 50;
jQuery(‘#page-header-21’).css(“background-position”, newvalueX+”px “+newvalueY+”px”);
});
});
</script>June 19, 2018 at 5:22 am #603429DavidStaffCustomer SupportHi David try this:
<script> jQuery(document).ready(function() { var movementStrength = 25; var height = movementStrength / jQuery(window).height(); var width = movementStrength / jQuery(window).width(); jQuery("#page-header-21").mousemove(function(e){ var pageX = e.pageX - (jQuery(window).width() / 2); var pageY = e.pageY - (jQuery(window).height() / 2); var newvalueX = width * pageX * -1 - 25; var newvalueY = height * pageY * -1 - 50; jQuery('#page-header-21').css("background-position", newvalueX+"px "+newvalueY+"px"); }); }); </script>
June 19, 2018 at 5:25 am #603431DavidStill not working – can I send you the admin logins privately, so you can double check?
June 19, 2018 at 5:34 am #603443DavidStaffCustomer SupportOK – we need to load jQuery. So add this snippet, heres how, i would recommend the code snippets plugin:
https://docs.generatepress.com/article/adding-php/
add_action( 'wp_enqueue_scripts', 'tu_load_jquery' ); function tu_load_jquery() { wp_enqueue_script( 'jquery' ); }
June 19, 2018 at 5:47 am #603453DavidThat’s done it 🙂 Thank you so much!
June 19, 2018 at 5:48 am #603454DavidStaffCustomer SupportGlad we got there!
June 19, 2018 at 5:50 am #603456DavidIs there an easy way to add it to all page headers, rather than me adding every page header ID?
June 19, 2018 at 6:01 am #603461DavidStaffCustomer SupportYou can replace the two instances of the
#page-header-21
with.generate-content-header
June 19, 2018 at 6:05 am #603466DavidGreat – last question…
The color overlay doesn’t go to the bottom now, is there anything I can do via CSS to change this?
-
AuthorPosts
- You must be logged in to reply to this topic.