@vizabi/combo
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -1,7 +0,7 @@ | ||
// https://github.com/vizabi/combo#readme v1.0.2 build 1711141716470 Copyright 2024 Gapminder Foundation and contributors | ||
// https://github.com/vizabi/combo#readme v1.1.0 build 1711218843024 Copyright 2024 Gapminder Foundation and contributors | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@vizabi/shared-components')) : | ||
typeof define === 'function' && define.amd ? define(['exports', '@vizabi/shared-components'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Combo = {}, global.VizabiSharedComponents)); | ||
})(this, (function (exports, sharedComponents) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('mobx'), require('@vizabi/shared-components')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'mobx', '@vizabi/shared-components'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Combo = {}, global.mobx, global.VizabiSharedComponents)); | ||
})(this, (function (exports, mobx, sharedComponents) { 'use strict'; | ||
@@ -172,12 +172,16 @@ const SPLIT_DIRECTION_ICON = ` | ||
.on("end.update", (event, d) => { | ||
if (_this.root.ui.chart.splitVertical) { | ||
_this.root.ui.chart.splitRatio = +((d._x / _this.toolWidth).toFixed(2)); | ||
} else { | ||
_this.root.ui.chart.splitRatio = +((d._y / _this.toolHeight).toFixed(2)); | ||
} | ||
mobx.runInAction(() => { | ||
if (_this.root.ui.chart.splitVertical) { | ||
_this.root.ui.chart.splitRatio = +((d._x / _this.toolWidth).toFixed(2)); | ||
} else { | ||
_this.root.ui.chart.splitRatio = +((d._y / _this.toolHeight).toFixed(2)); | ||
} | ||
}); | ||
}) | ||
); | ||
this.DOM.splitDirectionButton.on("click", () => { | ||
this.root.ui.chart.splitVertical = !this.root.ui.chart.splitVertical; | ||
this.root.ui.chart.splitRatio = 0.5; | ||
mobx.runInAction(() => { | ||
this.root.ui.chart.splitVertical = !this.root.ui.chart.splitVertical; | ||
this.root.ui.chart.splitRatio = 0.5; | ||
}); | ||
}); | ||
@@ -187,19 +191,20 @@ | ||
changeSplitDirection() { | ||
changeSplitRatioOrDirection() { | ||
const styleAttr = this.DOM.comboTool.attr("style"); | ||
const classAttr = this.DOM.comboTool.attr("class"); | ||
const splitVertical = this.root.ui.chart.splitVertical; | ||
const splitDirectionClasses = ["vzb-split-horizontal", "vzb-split-vertical"]; | ||
const classArray = this.root.ui.chart.splitVertical ? splitDirectionClasses : splitDirectionClasses.reverse(); | ||
this.DOM.comboTool.classed(classArray[0], false); | ||
this.DOM.comboTool.classed(classArray[1], true); | ||
setTimeout(() => { | ||
this.services.layout._resizeHandler(); | ||
}, 0); | ||
} | ||
const classArray = splitVertical ? splitDirectionClasses : splitDirectionClasses.reverse(); | ||
if (classAttr.includes(classArray[0])) { | ||
this.DOM.comboTool.classed(classArray[0], false); | ||
this.DOM.comboTool.classed(classArray[1], true); | ||
} | ||
changeSplitRatio() { | ||
const ratio = this.root.ui.chart.splitRatio; | ||
const newStyleAttr = (splitVertical ? "grid-template-columns" : "grid-template-rows") + `: ${ratio}fr ${Math.floor(100-ratio*100)/100}fr`; | ||
if (this.root.ui.chart.splitVertical) { | ||
this.DOM.comboTool.attr("style", `grid-template-columns: ${ratio}fr ${Math.floor(100-ratio*100)/100}fr`); | ||
} else { | ||
this.DOM.comboTool.attr("style", `grid-template-rows: ${ratio}fr ${Math.floor(100-ratio*100)/100}fr`); | ||
if (newStyleAttr !== styleAttr) { | ||
this.DOM.comboTool.attr("style", newStyleAttr); | ||
} | ||
@@ -219,5 +224,4 @@ setTimeout(() => { | ||
draw() { | ||
this.addReaction(this.changeSplitDirection); | ||
this.addReaction(this.resize); | ||
this.addReaction(this.changeSplitRatio); | ||
this.addReaction(this.changeSplitRatioOrDirection); | ||
} | ||
@@ -233,3 +237,3 @@ | ||
Combo.versionInfo = { version: "1.0.2", build: 1711141716470, package: {"homepage":"https://github.com/vizabi/combo#readme","name":"@vizabi/combo","description":"Vizabi combo"}, sharedComponents: sharedComponents.versionInfo}; | ||
Combo.versionInfo = { version: "1.1.0", build: 1711218843024, package: {"homepage":"https://github.com/vizabi/combo#readme","name":"@vizabi/combo","description":"Vizabi combo"}, sharedComponents: sharedComponents.versionInfo}; | ||
@@ -236,0 +240,0 @@ exports.Base = Combo; |
{ | ||
"name": "@vizabi/combo", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "Vizabi combo", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
185931
288