WordPress.org

Ready to get started?Download WordPress

Forums

Setting up FlowType.JS (4 posts)

  1. Luke Janicke
    Member
    Posted 9 months ago #

    I need some help getting FlowType working in a theme.

    I downloaded the FlowType.JS file from Github and put it in my theme directory.

    I used the following code in functions.php to enqueue it (with jQuery dependency).

    function custom_scripts() {
        wp_enqueue_script(
            'typeflow',
            get_stylesheet_directory_uri() . '/typeflow.js',
            array( 'jquery' )
        );
    }
    add_action( 'wp_enqueue_scripts', 'custom_scripts' );

    Then I added the following script just before the closing </body> tag in my theme.

    <script>
        $('body').flowtype();
    </script>

    I am testing it on an iPhone by rotating the phone from portrait to landscape. None of the text enlarges and shrinks. Can anyone help me out with that?

    Links:
    http://simplefocus.com/flowtype/
    https://github.com/simplefocus/FlowType.JS
    http://codex.wordpress.org/Function_Reference/wp_enqueue_script

  2. Hermie1964
    Member
    Posted 9 months ago #

    I think you need to wrap the $('body').flowtype(); code in:

    jQuery(document).ready(function($) {
    // Inside of this function, $() will work as an alias for jQuery()
    // and other libraries also using $ will not be accessible under this shortcut
    });

    See http://codex.wordpress.org/Function_Reference/wp_enqueue_script

  3. Hermie1964
    Member
    Posted 9 months ago #

    Both of these should work:

    jQuery(document).ready(function($){
    $('body').flowtype();
    });

    jQuery(document).ready(function(){
    jQuery('body').flowtype();
    });

  4. ronr1999
    Member
    Posted 1 month ago #

    I'm sure that he's caught this by now but someone else may try it and fail...

    get_stylesheet_directory_uri() . '/typeflow.js',

    Instead of "typeflow" it should be "flowtype".

Reply

You must log in to post.

About this Topic