Autoscroll
-
Thank you for everything. Is there a way to make the toggles autoscroll down if the text is off the page?
Thanks.
-
You’re welcome. To answer your question, no, not at this time.
Ok. Thanks.
John,
This is outside the issue of support, but hopefully you can point me in the right direction as I am learning to code. You really helped me with the shortcode in the other post.
Assume I now wanted to use arconix-shortcodes.js and shortcodes.php as the basis for my own toggle shortcode and then I wished to add auto-scroll.
Would I recreate separate php and js files in the protected areas of my child theme (I use Genesis Dynamik)? Then, do you have any recommendations on pointing me in the write direction to add autoscroll to your toggle?
Thanks again for helping me and to anybody reading this thread, John has been great supporting the plugin and has been going the extra mile in giving me advice as I begin to develop coding capabilities.
Thanks,
MichaelWould I recreate separate php and js files in the protected areas of my child theme (I use Genesis Dynamik)?
No. You would make a copy of
arconix-shortcodes.js
and place it in the root of your theme folder. My plugin will load your copy in place of mine. That way you can make upgrade-safe changes. If you need to add a shortcode, you can copy anything out of theshortcodes.php
file in terms of the actual shortcode functions, following the tutorials mentioned above, but put that in your theme’sfunctions.php
fileAs far as autoscroll specifically, my guess is you’d have to put the logic after line 22 or 26 in the js file… that will take a bit of testing unless you’re certain ahead of time where it would go.
I think I have it working. Thank you for all of your help. I only tested it on a few scenarios. Here is the code if you wish to include it in the next version or if anybody else wishes to use it.
Line 57 I removed/commented out:
jQuery(this).next('.arconix-toggle-content').slideToggle();
I then replaced it with:
jQuery(this).next('.arconix-toggle-content').slideToggle('slow', function() { if (jQuery(this).is(':visible')) { jQuery('html, body').animate({ scrollTop: jQuery(this).prev().offset().top},'slow') } });
By the way, how am I supposed to do the indenting in writing code? Sorry my questions are so basic, but I am just starting out. Thank you.
normally indenting is 4 spaces (though depending on the editor you’re using the Tab key can mimic 4 spaces).
John,
Thanks.
Is there any way to place arconix-shortcodes.js in a folder under the root directory rather than the root directory itself? The reason why I ask is that I use Dynamik theme and I can protect folders from deletion upon updating, but not files. So, my arconix-shortcodes.js file will be deleted when my theme updates.
Thanks,
MichaelIs there any way to place arconix-shortcodes.js in a folder under the root directory rather than the root directory itself?
Yes, but it gets a little more complicated.
you’d add the following to your theme’s
functions.php
add_filter( 'pre_register_arconix_shortcodes_js', '__return_false' );
That will prevent my shortcodes javascript from loading at all. Then you’d have to register your script using whatever location you’d like.
add_action( 'wp_enqueue_scripts', 'arconix_scripts' ); function arconix_scripts() { wp_register_script( 'arconix-shortcodes-js', [ENTER PATH HERE] . '/arconix-shortcodes.js', array( 'jquery-tools' ), '1.0', true ); }
That worked. Thanks. So is the reason you can write an “add_filter” function because the orignal php code is written with apply_filters.
Sometimes I can just add new PhP whereas other times I have to change the source code. I was wondering if the difference is whether the original source code was written a certain way. Thanks for all of your help.
So is the reason you can write an “add_filter” function because the orignal php code is written with apply_filters
Yes.
I was wondering if the difference is whether the original source code was written a certain way.
That’s correct. I try to add filters wherever I can to give developers down the line additional flexibility… not all developers do that.
- The topic ‘Autoscroll’ is closed to new replies.