svgdotjs / svg.js

The lightweight library for manipulating and animating SVG
https://svgjs.dev
Other
10.97k stars 1.07k forks source link

SVG.JS elements ordering #1268

Closed SilverGaucho closed 2 years ago

SilverGaucho commented 2 years ago

Maybe someone can help me here. Probably is a stupid question...but I try I want to load svg.js elements from file and restore their drawing order. I can save the order on file and load it and store in a variable but then it reach maximum call stack when I use the following function:

//Order loaded element
    function ordering(el,order){
        console.log('ordering '+ el.position(), order)
        if(el.position() > order){
            el.backward();
            ordering(el,order);
        } else if(el.position() < order){
            el.forward();
            ordering(el,order);
        } else {
            return;
        }

    }

any suggestion? THX by the way

Fuzzyma commented 2 years ago

This is not a support forum. Please use stackoverflow if you have any questions. A lot more people will be able to help there