MrFrankel / ruler

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

Tool tips on guides don't adjust to scale #19

Open graphics-et-al opened 3 years ago

graphics-et-al commented 3 years ago

When scaling a ruler, the labels on the tooltips don't show the new scale. To reproduce: 1) Show a ruler, e.g. at https://mrfrankel.github.io/ruler/ 2) Set a scale to something other than 1 3) Drag a guide to see the tooltip

Expected: tooltip on guide shows scaled measurement Got: no scaling. image

graphics-et-al commented 3 years ago

Proposed fix: var attachListeners = function (container, curRul) { var mousedown = function (e) { constructGuide(curRul.dimension, e.clientX, e.clientY, e); // fix guide scale here guides.forEach(function (guide) { if (guide.dimension === HORIZONTAL) { guide.line.curScale(curRul.getScale()); } else { guide.line.curScale(curRul.getScale()); } }); }; curRul.canvas.addEventListener('mousedown', mousedown); curRul.clearListeners = function () { curRul.canvas.removeEventListener('mousedown', mousedown); } };