Skip to content

Commit f7d3bbd

Browse files
author
Martin Hansen
committed
Using react for resize event
1 parent f8ac5e8 commit f7d3bbd

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed

dist/vue-plotly.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ exports = module.exports = __webpack_require__(26)(false);
651651

652652

653653
// module
654-
exports.push([module.i, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", ""]);
654+
exports.push([module.i, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", ""]);
655655

656656
// exports
657657

@@ -1137,7 +1137,10 @@ var methods = functions.reduce(function (all, funcName) {
11371137
var _this3 = this;
11381138

11391139
if (this.autoResize) {
1140-
this.__resizeListener = __WEBPACK_IMPORTED_MODULE_2_lodash_debounce___default()(this.newPlot, 200);
1140+
this.__resizeListener = function () {
1141+
_this3.internalLayout.datarevision++;
1142+
__WEBPACK_IMPORTED_MODULE_2_lodash_debounce___default()(_this3.react, 200);
1143+
};
11411144
window.addEventListener('resize', this.__resizeListener);
11421145
}
11431146

@@ -1181,20 +1184,24 @@ var methods = functions.reduce(function (all, funcName) {
11811184
return __WEBPACK_IMPORTED_MODULE_1_plotly_js___default.a.downloadImage(this.$refs.container, opts);
11821185
},
11831186
plot: function plot() {
1184-
return __WEBPACK_IMPORTED_MODULE_1_plotly_js___default.a.plot(this.$refs.container, this.data, this.internalLayout, this.options);
1187+
return __WEBPACK_IMPORTED_MODULE_1_plotly_js___default.a.plot(this.$refs.container, this.data, this.internalLayout, this.getOptions());
11851188
},
1186-
newPlot: function newPlot() {
1189+
getOptions: function getOptions() {
11871190
var el = this.$refs.container;
1188-
1189-
//if width/height is not specified for toImageButton, default to el.clientWidth/clientHeight
1190-
if (!this.options) this.options = {};
1191-
if (!this.options.toImageButtonOptions) this.options.toImageButtonOptions = {};
1192-
if (!this.options.toImageButtonOptions.width) this.options.toImageButtonOptions.width = el.clientWidth;
1193-
if (!this.options.toImageButtonOptions.height) this.options.toImageButtonOptions.height = el.clientHeight;
1194-
return __WEBPACK_IMPORTED_MODULE_1_plotly_js___default.a.newPlot(this.$refs.container, this.data, this.internalLayout, this.options);
1191+
var opts = this.options;
1192+
1193+
// if width/height is not specified for toImageButton, default to el.clientWidth/clientHeight
1194+
if (!opts) opts = {};
1195+
if (!opts.toImageButtonOptions) opts.toImageButtonOptions = {};
1196+
if (!opts.toImageButtonOptions.width) opts.toImageButtonOptions.width = el.clientWidth;
1197+
if (!opts.toImageButtonOptions.height) opts.toImageButtonOptions.height = el.clientHeight;
1198+
return opts;
1199+
},
1200+
newPlot: function newPlot() {
1201+
return __WEBPACK_IMPORTED_MODULE_1_plotly_js___default.a.newPlot(this.$refs.container, this.data, this.internalLayout, this.getOptions());
11951202
},
11961203
react: function react() {
1197-
return __WEBPACK_IMPORTED_MODULE_1_plotly_js___default.a.react(this.$refs.container, this.data, this.internalLayout, this.options);
1204+
return __WEBPACK_IMPORTED_MODULE_1_plotly_js___default.a.react(this.$refs.container, this.data, this.internalLayout, this.getOptions());
11981205
}
11991206
})
12001207
});

0 commit comments

Comments
 (0)