|
1 | 1 | var Plotly = require('@lib/index');
|
2 | 2 | var Plots = Plotly.Plots;
|
3 | 3 | var Lib = require('@src/lib');
|
| 4 | + |
| 5 | +var d3 = require('d3'); |
4 | 6 | var createGraphDiv = require('../assets/create_graph_div');
|
5 | 7 | var destroyGraphDiv = require('../assets/destroy_graph_div');
|
6 | 8 | var click = require('../assets/click');
|
@@ -760,4 +762,55 @@ describe('config argument', function() {
|
760 | 762 | .then(done);
|
761 | 763 | });
|
762 | 764 | });
|
| 765 | + |
| 766 | + describe('scrollZoom interactions:', function() { |
| 767 | + var gd; |
| 768 | + |
| 769 | + afterEach(function() { |
| 770 | + Plotly.purge(gd); |
| 771 | + destroyGraphDiv(); |
| 772 | + }); |
| 773 | + |
| 774 | + function _scroll() { |
| 775 | + var mainDrag = d3.select('.nsewdrag[data-subplot="xy"]').node(); |
| 776 | + mouseEvent('scroll', 200, 200, {deltaY: -200, element: mainDrag}); |
| 777 | + } |
| 778 | + |
| 779 | + it('should not disable scrollZoom when *responsive:true*', function(done) { |
| 780 | + gd = document.createElement('div'); |
| 781 | + gd.id = 'graph'; |
| 782 | + gd.style.height = '85vh'; |
| 783 | + gd.style.minHeight = '300px'; |
| 784 | + document.body.appendChild(gd); |
| 785 | + |
| 786 | + // locking down fix for: |
| 787 | + // https://github.com/plotly/plotly.js/issues/3337 |
| 788 | + |
| 789 | + var xrng0; |
| 790 | + var yrng0; |
| 791 | + |
| 792 | + Plotly.newPlot(gd, [{ |
| 793 | + y: [1, 2, 1] |
| 794 | + }], {}, { |
| 795 | + scrollZoom: true, |
| 796 | + responsive: true |
| 797 | + }) |
| 798 | + .then(function() { |
| 799 | + xrng0 = gd._fullLayout.xaxis.range.slice(); |
| 800 | + yrng0 = gd._fullLayout.yaxis.range.slice(); |
| 801 | + }) |
| 802 | + .then(_scroll) |
| 803 | + .then(function() { |
| 804 | + var xrng = gd._fullLayout.xaxis.range; |
| 805 | + expect(xrng[0]).toBeGreaterThan(xrng0[0], 'scrolled x-range[0]'); |
| 806 | + expect(xrng[1]).toBeLessThan(xrng0[1], 'scrolled x-range[1]'); |
| 807 | + |
| 808 | + var yrng = gd._fullLayout.yaxis.range; |
| 809 | + expect(yrng[0]).toBeGreaterThan(yrng0[0], 'scrolled y-range[0]'); |
| 810 | + expect(yrng[1]).toBeLessThan(yrng0[1], 'scrolled y-range[1]'); |
| 811 | + }) |
| 812 | + .catch(failTest) |
| 813 | + .then(done); |
| 814 | + }); |
| 815 | + }); |
763 | 816 | });
|
0 commit comments