From a049bc82e855589a8cdc7fa3e58fed4c1b67a5fa Mon Sep 17 00:00:00 2001 From: 2deep4real <denis.peters@udo.edu> Date: Wed, 1 Jul 2015 01:02:00 +0200 Subject: [PATCH] fixed resize in panel/scrollbar --- panels/scrollbar/script.js | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/panels/scrollbar/script.js b/panels/scrollbar/script.js index 09d0d80..76df35f 100755 --- a/panels/scrollbar/script.js +++ b/panels/scrollbar/script.js @@ -1,6 +1,7 @@ +var CM; + this.loaded = function(panel, config) { console.log("scrollbar: register with config [" + config + "]"); - var CM; function CanvasMarquee() { var @@ -10,7 +11,7 @@ this.loaded = function(panel, config) { font = "vrr", baseline = 0.7, textID = -1, - amount = 2, + amount = 5, delay = 2, width = 0, height = 0, @@ -23,9 +24,8 @@ this.loaded = function(panel, config) { init = function() { marquee = $(panel).find('[data-marquee]')[0]; width = $(panel).width(); - height = $(panel).height(); + height = $(panel).height(); $(marquee).attr('width', width).attr('height', height); - width = $(marquee).width(); mctx = marquee.getContext('2d'); } @@ -65,18 +65,19 @@ this.loaded = function(panel, config) { } prerender = function() { - var fsize = height; - mctx.font = fsize + "px " + font; + mctx.font = height + "px " + font; + texts = []; for (var i = 0; i < strings.length; ++i) { var - text = '+++ ' + strings[i].join(' +++ +++ ') + ' +++', + text = '+++ ' + strings[i].join(' +++ +++ ') + ' +++', bWidth = mctx.measureText(text).width, - buffer = document.createElement('canvas'); - $(buffer).attr("width", bWidth); + buffer = document.createElement('canvas'), + bctx; + $(buffer).attr('width', bWidth).attr('height', height); bctx = buffer.getContext('2d'); - bctx.font = fsize + "px " + font; + bctx.font = height + "px " + font; bctx.fillStyle = fgColor; - bctx.fillText(text, 0, fsize * baseline); + bctx.fillText(text, 0, height * baseline); texts.push({ 'text' : buffer, 'width' : bWidth @@ -89,7 +90,17 @@ this.loaded = function(panel, config) { $.get("config/panel/scrollbar/oh14.json", function(decodedData) { CM = new CanvasMarquee(); CM.setTexts(decodedData.texts); - $(window).resize(CM.resize); }); + r = function() { + resize(); + } + + $(window).resize(r); + } + +var resize = function() { + if (CM) + CM.resize(); +} \ No newline at end of file -- GitLab