MrFrankel / ruler

HTML5 Canvas ruler for authoring tools
http://mrfrankel.github.io/ruler/
221 stars 56 forks source link

Apply ruler (with same guidelines) to multiple elements #2

Closed SenorWesley closed 7 years ago

SenorWesley commented 7 years ago

I have multiple elements, all with the same class name. Would it be an idea to make it so I can enable the ruler on all of these with the same lines?

Thanks.

MrFrankel commented 7 years ago

I just pushed in a new version that exposes two more API calls. getGuides(); setGuides();

getGuides gives you a list of guides METADATA that you can store in a variable or convert to JSON. setGuides consumes this list and applies it to a given ruler.

This way you can copy guides from one ruler to the other.

Haven't had time to test it much, let me know how it goes.

SenorWesley commented 7 years ago

Worked like a charm, thanks for implementing this!

SenorWesley commented 7 years ago

Another question though, is there a possibility to place the ruler on an absolute positioned element? When I try it, the lines won't "stick"

MrFrankel commented 7 years ago

Seems to work for me, can you provide an example? plunker/codepen etc...?