From c37c5c6601f2bd0f46a629bab1ecd6207bd4fae8 Mon Sep 17 00:00:00 2001 From: Maxim Khlobystov Date: Wed, 10 Sep 2014 17:02:13 -0700 Subject: [PATCH] Implemented slide zooming and panning (horizontally and vertically). --- .../whiteboard_models/whiteboard_paper.coffee | 26 +++++++++++++++++++ labs/meteor-client/server/redispubsub.coffee | 5 +++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/labs/meteor-client/client/whiteboard_models/whiteboard_paper.coffee b/labs/meteor-client/client/whiteboard_models/whiteboard_paper.coffee index 532190575d..9033daf7bb 100755 --- a/labs/meteor-client/client/whiteboard_models/whiteboard_paper.coffee +++ b/labs/meteor-client/client/whiteboard_models/whiteboard_paper.coffee @@ -362,6 +362,21 @@ class @WhiteboardPaperModel # Updated a shape `shape` with the data in `data`. # TODO: check if the objects exist before calling update, if they don't they should be created updateShape: (shape, data) -> + console.log "FUNCTION updateShape" + ###currentPresentation = Meteor.Presentations.findOne({"presentation.current": true}) + presentationId = currentPresentation?.presentation?.id + slidesCursor = Meteor.Slides.find({"presentationId": presentationId, "slide.current": true}) + console.log "slidesCursor:" + console.log slidesCursor + + slidesCursor.observe + added: (document) -> + console.log "ADDED:" + console.log document.slide.width_ratio + changed: (newDocument, oldDocument) -> + console.log "CHANGED:" + console.log newDocument.slide.width_ratio### + switch shape when "line" @currentLine.update(data) @@ -823,6 +838,17 @@ class @WhiteboardPaperModel # console.log "boardHeight: #{boardHeight}" console.log "imageWidth: #{imageWidth}" console.log "imageHeight: #{imageHeight}" + + currentSlideCursor = Meteor.Slides.find({"presentationId": presentationId, "slide.current": true}) + _raphaelObj = @raphaelObj + + currentSlideCursor.observe # watching the current slide changes + changed: (newDoc, oldDoc) -> + newX = - newDoc.slide.x_offset * 2 * boardWidth / 100 + newY = - newDoc.slide.y_offset * 2 * boardHeight / 100 + newWidth = boardWidth * newDoc.slide.width_ratio / 100 + newHeight = boardHeight * newDoc.slide.height_ratio / 100 + _raphaelObj.setViewBox(newX, newY, newWidth, newHeight) # zooms and pans pic = new Image() _this = this diff --git a/labs/meteor-client/server/redispubsub.coffee b/labs/meteor-client/server/redispubsub.coffee index 5b9e677c20..9f3ceed0a8 100755 --- a/labs/meteor-client/server/redispubsub.coffee +++ b/labs/meteor-client/server/redispubsub.coffee @@ -319,7 +319,10 @@ class Meteor.RedisPubSub widthRatio = message.payload?.page?.width_ratio xOffset = message.payload?.page?.x_offset yOffset = message.payload?.page?.y_offset - console.log "__#{slideId}___#{heightRatio}___#{widthRatio}___#{xOffset}__#{yOffset}__" + presentationId = slideId.split("/")[0] + Meteor.Slides.update({presentationId: presentationId, "slide.current": true}, + {$set: {"slide.height_ratio": heightRatio, "slide.width_ratio": widthRatio, "slide.x_offset": xOffset, "slide.y_offset": yOffset}}) + console.log "__#{presentationId}___#{slideId}___#{heightRatio}___#{widthRatio}___#{xOffset}__#{yOffset}__" if message.header?.name is "user_raised_hand_message" userId = message.payload?.userid