Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Benbodhi

    (@benbodhi)

    Hi ben_del,

    Thanks for your support ??
    That sounds like a pretty useful suggestion. Would you mind sharing your use case with me so I can better understand what you want to achieve with this functionality?

    Cheers
    Ben

    Thread Starter ben_del

    (@ben_del)

    In my case, I’m animating certain elements of the SVG code using JavaScript. But since the SVG code is loaded after the page load has finished, my animation script is failing, as there is no code present to animate (yet) when it fires.

    So, it would be useful if I could specify a callback function(s) that would be fired at the ‘complete’ event of the get request for the SVG code.

    I could see two ways to do it:

    1) A ‘global’ function to call, which would receive each given SVG as an argument. This could be an option of the plugin. Just a simple text field that would store a function name, which would then be called, passing each returned SVG as it’s main argument each time it’s called. This would be useful if, say, I knew that ALL my animations were going to need to fire an “animateSVG” function.

    2) SVG-specific function names. This could perhaps be assigned PER SVG. Somehow at the point of insertion/selection of the SVG image in the WP editor, a function name could be supplied by the user. This would then be stored as a data-callback-XXX attribute on the rendered SVG root node. Then the SVG Support script would search the DOM at the onComplete for elements that had a data-callback- prefix and fire their corresponding functions, again, passing the SVG element as an argument to the specified function.

    Those are just how I saw it happening. I’m sure there are many ways you could do it.

    Thanks for the reply and for considering the feature addition.

    best,

    Ben

    Plugin Author Benbodhi

    (@benbodhi)

    Well that certainly sounds pretty helpful.
    I won’t get a chance to work on this for a while unfortunately, but will keep it in mind.
    Cheers

    Plugin Author Benbodhi

    (@benbodhi)

    Hey, I’m working on a few things for the next update and had a play with this idea… but I’m no JS expert and keep having trouble figuring out the best way to do this…
    I wonder if you have any time to write in your own code how you personally would use it? I would appreciate any help you can offer!

    Plugin Author Benbodhi

    (@benbodhi)

    I have added a new class with +index on the end, so each SVG rendered has a unique class for targeting… Not sure if this will help you, let me know your thoughts.
    The new JS file is in the dev version in trunk if you would like to test it.

    Plugin Author Benbodhi

    (@benbodhi)

    I have released these features live now, so will mark as resolved

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Callback Option … ?’ is closed to new replies.