@antv/f6-plugin
Version:
F6 plugin
44 lines (34 loc) • 2.16 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _f6Ui = require("@antv/f6-ui");
var _dispatcher = require("../../dispatcher");
var _const = require("../../utils/const");
function createPlayBtn(style) {
var _a = style || {},
_b = _a.radius,
radius = _b === void 0 ? 15 : _b,
fill = _a.fill; // 播放按钮中间三角形的高
var triH = radius * Math.sqrt(3) / 2;
var html = "\n <div id='play_Btn'>\n <shape class=\"start\" type='path' path='[\n [\"M\", 0 , 0],\n [\"L\", " + triH + " , " + radius / 2 + "],\n [\"L\", 0 , " + radius + "]\n ]'/>\n <div class=\"pause\">\n <shape class='pause_0' type='rect' />\n <shape class='pause_1' type='rect' />\n </div>\n </div>";
var css = "\n #play_Btn {\n width: " + radius * 2 + ";\n height: " + radius * 2 + ";\n background: #fff;\n border: 1 solid " + fill + ";\n border-radius: " + radius + ";\n }\n .start{\n position: absolute;\n top: " + radius / 2 + ";\n left: " + (radius - triH / 2 + 1) + " ;\n background: " + fill + ";\n width: " + radius + ";\n height: " + radius + ";\n }\n .pause {\n display: none;\n }\n .pause shape {\n position: absolute;\n background: " + fill + ";\n width: " + radius / 4 + ";\n height: " + radius + ";\n }\n .pause_1 {\n left: " + 4 * radius / 8 + ";\n }\n .pause {\n position: absolute;\n top: " + radius / 2 + ";\n left: " + 5 * radius / 8 + ";\n }\n ";
var node = (0, _f6Ui.createSegmentNode)(html, css);
var startNode = node.query('.start');
var pauseNode = node.query('.pause');
var isPause = true;
function update() {
startNode.setStyle('display', isPause ? 'flex' : 'none');
pauseNode.setStyle('display', isPause ? 'none' : 'flex');
}
update();
node.on('tap', function () {
(0, _dispatcher.dispatch)(isPause ? _const.SLIDER_PLAY : _const.SLIDER_PAUSE);
isPause = !isPause;
update();
});
return node;
}
var _default = createPlayBtn;
exports.default = _default;