From 434699bf23d69827177944796fb1ae732a0e95d1 Mon Sep 17 00:00:00 2001 From: primalmotion Date: Tue, 3 Aug 2010 13:52:56 +0200 Subject: [PATCH] * Port to be Cappuccino compatible (need to use GLOBAL() in fiture) * Reverting to my zoom method --- include/canvas.js | 52 +++++++++++++++++++++++++++++------------------ include/rfb.js | 5 ++--- 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/include/canvas.js b/include/canvas.js index 7b02b3e..11b28bc 100644 --- a/include/canvas.js +++ b/include/canvas.js @@ -6,11 +6,11 @@ * See README.md for usage and integration instructions. */ -"use strict"; +//"use strict"; /*jslint browser: true, white: false, bitwise: false */ /*global window, Util, Base64 */ -function Canvas(conf) { +Canvas = function(conf) { conf = conf || {}; // Configuration var that = {}, // Public API interface @@ -76,8 +76,6 @@ that.get_height = function() { return c_height; }; - - // // Private functions // @@ -403,30 +401,44 @@ that.start = function(keyPressFunc, mouseButtonFunc, mouseMoveFunc) { that.rescale = function(factor) { var c, tp, x, y, - properties = ['transform', 'WebkitTransform', 'MozTransform', null]; + properties = ['transform', 'WebkitTransform', 'MozTransform', 'oTransform', null], + origin = ['transformOrigin', 'WebkitTransformOrigin', 'MozTransformOrigin', 'oTransformOrigin', null]; + + if (conf.scale === factor) { + return; + } + c = conf.target; - tp = properties.shift(); - while (tp) { - if (typeof c.style[tp] !== 'undefined') { + conf.scale = factor; + x = c.width - c.width * factor; + y = c.height - c.height * factor; + + //tp = properties.shift(); + + if (typeof(c.style.zoom) != "undefined") { + c.style.zoom = conf.scale; + return + } + + while (tp = properties.shift()) { + if (typeof c.style[tp] != 'undefined') { break; } - tp = properties.shift(); } - + + while (tpo = origin.shift()) { + if (typeof c.style[tpo] != 'undefined') { + break; + } + } + if (tp === null) { Util.Debug("No scaling support"); return; } - - if (conf.scale === factor) { - //Util.Debug("Canvas already scaled to '" + factor + "'"); - return; - } - - conf.scale = factor; - x = c.width - c.width * factor; - y = c.height - c.height * factor; - c.style[tp] = "scale(" + conf.scale + ") translate(-" + x + "px, -" + y + "px)"; + + c.style[tpo] = "top left"; + c.style[tp] = "scale(" + conf.scale + ")"; }; that.resize = function(width, height, true_color) { diff --git a/include/rfb.js b/include/rfb.js index 766f6eb..b8ee089 100644 --- a/include/rfb.js +++ b/include/rfb.js @@ -6,13 +6,12 @@ * See README.md for usage and integration instructions. */ -"use strict"; +//"use strict"; /*jslint white: false, browser: true, bitwise: false */ /*global window, WebSocket, Util, Canvas, VNC_native_ws, Base64, DES */ -function RFB(conf) { - +RFB = function(conf) { conf = conf || {}; // Configuration var that = {}, // Public API interface