2014-12-03 02:09:20 +00:00
|
|
|
import _ from 'lodash';
|
|
|
|
import Base from './base.js';
|
|
|
|
|
|
|
|
export default _.extend({}, Base, {
|
2014-12-06 17:34:00 +00:00
|
|
|
type: 'match_fragment',
|
|
|
|
|
|
|
|
render() {
|
|
|
|
this._content.container = this.container.group();
|
|
|
|
this._content.render();
|
|
|
|
},
|
|
|
|
|
|
|
|
position() {
|
|
|
|
var box, paths = [];
|
|
|
|
|
|
|
|
this._content.position();
|
|
|
|
|
|
|
|
if (this._repeat.textValue !== '') {
|
2014-12-09 23:08:40 +00:00
|
|
|
this._content.container.transform(this._repeat.contentPosition());
|
2014-12-06 17:34:00 +00:00
|
|
|
|
|
|
|
box = this._content.container.getBBox();
|
|
|
|
|
2014-12-09 23:08:40 +00:00
|
|
|
if (this._repeat.hasSkip()) {
|
2014-12-06 17:34:00 +00:00
|
|
|
paths.push(Snap.format('M0,{cy}q10,0 10,-10v-{vert}q0,-10 10,-10h{horiz}q10,0 10,10v{vert}q0,10 10,10', _.extend({
|
|
|
|
vert: box.height / 2 - 10,
|
|
|
|
horiz: box.width - 10
|
|
|
|
}, box)));
|
|
|
|
}
|
|
|
|
|
2014-12-09 23:08:40 +00:00
|
|
|
if (this._repeat.hasLoop()) {
|
2014-12-06 17:34:00 +00:00
|
|
|
paths.push(Snap.format('M{x},{cy}q-10,0 -10,10v{vert}q0,10 10,10h{width}q10,0 10,-10v-{vert}q0,-10 -10,-10', _.extend({
|
|
|
|
vert: box.height / 2 - 10
|
|
|
|
}, box)));
|
|
|
|
}
|
|
|
|
|
2014-12-09 23:08:40 +00:00
|
|
|
if (this._repeat.hasLoop() || this._repeat.hasSkip()) {
|
2014-12-06 17:34:00 +00:00
|
|
|
paths.push(Snap.format('M0,{cy}h15M{x2},{cy}h15', box));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (paths.length) {
|
|
|
|
this.container.path(paths.join(''));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-12-03 02:09:20 +00:00
|
|
|
});
|