Browse Source

Clear the canvas offset on resize. Fixes #699

pull/803/head
Artur Arseniev 9 years ago
parent
commit
6a5b55a42c
  1. 3
      src/canvas/view/CanvasView.js
  2. 6
      test/specs/parser/model/ParserCss.js

3
src/canvas/view/CanvasView.js

@ -1,10 +1,11 @@
import { on, off } from 'utils/mixins';
const FrameView = require('./FrameView'); const FrameView = require('./FrameView');
const $ = Backbone.$; const $ = Backbone.$;
module.exports = Backbone.View.extend({ module.exports = Backbone.View.extend({
initialize(o) { initialize(o) {
_.bindAll(this, 'renderBody', 'onFrameScroll', 'clearOff'); _.bindAll(this, 'renderBody', 'onFrameScroll', 'clearOff');
window.onscroll = this.clearOff; on(window, 'scroll resize', this.clearOff);
this.config = o.config || {}; this.config = o.config || {};
this.em = this.config.em || {}; this.em = this.config.em || {};
this.ppfx = this.config.pStylePrefix || ''; this.ppfx = this.config.pStylePrefix || '';

6
test/specs/parser/model/ParserCss.js

@ -2,7 +2,7 @@ const ParserCss = require('parser/model/ParserCss');
module.exports = { module.exports = {
run() { run() {
describe.only('ParserCss', () => { describe('ParserCss', () => {
var obj; var obj;
beforeEach(() => { beforeEach(() => {
@ -133,6 +133,7 @@ module.exports = {
var str = var str =
'@media only screen and (max-width: 992px){ .test1.test2:hover{ color:red }}'; '@media only screen and (max-width: 992px){ .test1.test2:hover{ color:red }}';
var result = { var result = {
atRuleType: 'media',
selectors: ['test1', 'test2'], selectors: ['test1', 'test2'],
style: { color: 'red' }, style: { color: 'red' },
state: 'hover', state: 'hover',
@ -145,6 +146,7 @@ module.exports = {
it('Parse rule inside media query', () => { it('Parse rule inside media query', () => {
var str = '@media (max-width: 992px){ .test1.test2:hover{ color:red }}'; var str = '@media (max-width: 992px){ .test1.test2:hover{ color:red }}';
var result = { var result = {
atRuleType: 'media',
selectors: ['test1', 'test2'], selectors: ['test1', 'test2'],
style: { color: 'red' }, style: { color: 'red' },
state: 'hover', state: 'hover',
@ -167,11 +169,13 @@ module.exports = {
selectors: ['test1', 'test2'], selectors: ['test1', 'test2'],
style: { color: 'red' }, style: { color: 'red' },
state: 'hover', state: 'hover',
atRuleType: 'media',
mediaText: '(max-width: 992px)' mediaText: '(max-width: 992px)'
}, },
{ {
selectors: ['test2'], selectors: ['test2'],
style: { color: 'blue' }, style: { color: 'blue' },
atRuleType: 'media',
mediaText: '(max-width: 992px)' mediaText: '(max-width: 992px)'
} }
]; ];

Loading…
Cancel
Save