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) {
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment