Skip to content
Snippets Groups Projects
Commit a049bc82 authored by 2deep4real's avatar 2deep4real
Browse files

fixed resize in panel/scrollbar

parent b334fe6b
No related branches found
No related tags found
No related merge requests found
var CM;
this.loaded = function(panel, config) { this.loaded = function(panel, config) {
console.log("scrollbar: register with config [" + config + "]"); console.log("scrollbar: register with config [" + config + "]");
var CM;
function CanvasMarquee() { function CanvasMarquee() {
var var
...@@ -10,7 +11,7 @@ this.loaded = function(panel, config) { ...@@ -10,7 +11,7 @@ this.loaded = function(panel, config) {
font = "vrr", font = "vrr",
baseline = 0.7, baseline = 0.7,
textID = -1, textID = -1,
amount = 2, amount = 5,
delay = 2, delay = 2,
width = 0, width = 0,
height = 0, height = 0,
...@@ -25,7 +26,6 @@ this.loaded = function(panel, config) { ...@@ -25,7 +26,6 @@ this.loaded = function(panel, config) {
width = $(panel).width(); width = $(panel).width();
height = $(panel).height(); height = $(panel).height();
$(marquee).attr('width', width).attr('height', height); $(marquee).attr('width', width).attr('height', height);
width = $(marquee).width();
mctx = marquee.getContext('2d'); mctx = marquee.getContext('2d');
} }
...@@ -65,18 +65,19 @@ this.loaded = function(panel, config) { ...@@ -65,18 +65,19 @@ this.loaded = function(panel, config) {
} }
prerender = function() { prerender = function() {
var fsize = height; mctx.font = height + "px " + font;
mctx.font = fsize + "px " + font; texts = [];
for (var i = 0; i < strings.length; ++i) { for (var i = 0; i < strings.length; ++i) {
var var
text = '+++ ' + strings[i].join(' +++ +++ ') + ' +++', text = '+++ ' + strings[i].join(' +++ +++ ') + ' +++',
bWidth = mctx.measureText(text).width, bWidth = mctx.measureText(text).width,
buffer = document.createElement('canvas'); buffer = document.createElement('canvas'),
$(buffer).attr("width", bWidth); bctx;
$(buffer).attr('width', bWidth).attr('height', height);
bctx = buffer.getContext('2d'); bctx = buffer.getContext('2d');
bctx.font = fsize + "px " + font; bctx.font = height + "px " + font;
bctx.fillStyle = fgColor; bctx.fillStyle = fgColor;
bctx.fillText(text, 0, fsize * baseline); bctx.fillText(text, 0, height * baseline);
texts.push({ texts.push({
'text' : buffer, 'text' : buffer,
'width' : bWidth 'width' : bWidth
...@@ -89,7 +90,17 @@ this.loaded = function(panel, config) { ...@@ -89,7 +90,17 @@ this.loaded = function(panel, config) {
$.get("config/panel/scrollbar/oh14.json", function(decodedData) { $.get("config/panel/scrollbar/oh14.json", function(decodedData) {
CM = new CanvasMarquee(); CM = new CanvasMarquee();
CM.setTexts(decodedData.texts); 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment