diff --git a/src/canvas/view/FrameWrapView.js b/src/canvas/view/FrameWrapView.js new file mode 100644 index 000000000..2b30b224a --- /dev/null +++ b/src/canvas/view/FrameWrapView.js @@ -0,0 +1,78 @@ +import Backbone from 'backbone'; +import FrameView from './FrameView'; +import { bindAll } from 'underscore'; +import { createEl } from 'utils/dom'; + +export default Backbone.View.extend({ + initialize(opts = {}, conf = {}) { + bindAll(this, 'onScroll', 'frameLoaded'); + const { model } = this; + const config = opts.config || conf; + const { canvasView } = config; + this.cv = canvasView; + this.config = config; + this.em = config.em; + this.ppfx = config.pStylePrefix || ''; + this.frame = new FrameView({ model, config }); + // this.listenTo(canvasView.model, 'change:zoom', this.canvasChange) + }, + + // canvasChange() { + // const zoom = this.config.module.getZoomMultiplier(); + // this.elTools.style.transform = `scale(${zoom})`; + // }, + + onScroll() { + const { frame, em } = this; + // const unit = 'px'; + // const { scrollTop, scrollLeft } = frame.getBody(); + // const { style } = this.elTools; + // style.top = `-${scrollTop}${unit}`; + // style.left = `-${scrollLeft}${unit}`; + em.trigger('frame:scroll', { + frame, + body: frame.getBody(), + target: frame.getWindow() + }); + }, + + frameLoaded() { + const { frame } = this; + frame.getWindow().onscroll = this.onScroll; + }, + + render() { + const { frame, $el, ppfx, cv } = this; + frame.render(); + $el + .empty() + .attr({ + class: `${ppfx}frame-wrapper` + }) + .append(frame.el); + const elTools = createEl( + 'div', + { + class: `${ppfx}tools`, + style: 'pointer-events:none' + }, + ` +
+
+
+
+
+
+
+
+
+
+ ` + ); + this.elTools = elTools; + cv.toolsWrapper.appendChild(elTools); + frame.on('loaded', this.frameLoaded); + + return this; + } +});