2014-12-03 02:09:20 +00:00
|
|
|
import _ from 'lodash';
|
|
|
|
import Base from './base.js';
|
|
|
|
|
|
|
|
export default _.extend({}, Base, {
|
2014-12-10 21:57:42 +00:00
|
|
|
type: 'match-fragment',
|
2014-12-06 17:34:00 +00:00
|
|
|
|
2014-12-11 00:01:57 +00:00
|
|
|
_render() {
|
2014-12-10 21:52:57 +00:00
|
|
|
if (this._repeat.textValue === '') {
|
2014-12-11 00:01:57 +00:00
|
|
|
this.proxy(this._content);
|
2014-12-10 21:52:57 +00:00
|
|
|
} else {
|
|
|
|
this._content.setContainer(this.container.group());
|
2014-12-11 00:01:57 +00:00
|
|
|
this._content.render();
|
2014-12-10 21:52:57 +00:00
|
|
|
}
|
2014-12-06 17:34:00 +00:00
|
|
|
},
|
|
|
|
|
2014-12-11 00:01:57 +00:00
|
|
|
_position() {
|
2014-12-06 17:34:00 +00:00
|
|
|
var box, paths = [];
|
|
|
|
|
|
|
|
this._content.position();
|
2014-12-11 00:01:57 +00:00
|
|
|
this._content.container.transform(this._repeat.contentPosition());
|
2014-12-06 17:34:00 +00:00
|
|
|
|
2014-12-11 00:01:57 +00:00
|
|
|
box = this._content.getBBox();
|
2014-12-06 17:34:00 +00:00
|
|
|
|
2014-12-11 00:01:57 +00:00
|
|
|
if (this._repeat.hasSkip()) {
|
2014-12-11 00:09:31 +00:00
|
|
|
paths.push(Snap.format('M0,{box.cy}q10,0 10,-10v-{vert}q0,-10 10,-10h{horiz}q10,0 10,10v{vert}q0,10 10,10', {
|
|
|
|
box,
|
2014-12-11 00:01:57 +00:00
|
|
|
vert: box.height / 2 - 10,
|
|
|
|
horiz: box.width - 10
|
2014-12-11 00:09:31 +00:00
|
|
|
}));
|
2014-12-11 00:01:57 +00:00
|
|
|
}
|
2014-12-06 17:34:00 +00:00
|
|
|
|
2014-12-11 00:01:57 +00:00
|
|
|
if (this._repeat.hasLoop()) {
|
2014-12-11 00:09:31 +00:00
|
|
|
paths.push(Snap.format('M{box.x},{box.cy}q-10,0 -10,10v{vert}q0,10 10,10h{box.width}q10,0 10,-10v-{vert}q0,-10 -10,-10', {
|
|
|
|
box,
|
2014-12-11 00:01:57 +00:00
|
|
|
vert: box.height / 2 - 10
|
2014-12-11 00:09:31 +00:00
|
|
|
}));
|
2014-12-11 00:01:57 +00:00
|
|
|
}
|
2014-12-06 17:34:00 +00:00
|
|
|
|
2014-12-11 00:01:57 +00:00
|
|
|
if (paths.length) {
|
2014-12-11 00:09:31 +00:00
|
|
|
this.container.prepend(
|
|
|
|
this.container.path(paths.join('')));
|
2014-12-06 17:34:00 +00:00
|
|
|
}
|
|
|
|
}
|
2014-12-03 02:09:20 +00:00
|
|
|
});
|