cursorHelper.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. /**
  20. * AUTO-GENERATED FILE. DO NOT MODIFY.
  21. */
  22. /*
  23. * Licensed to the Apache Software Foundation (ASF) under one
  24. * or more contributor license agreements. See the NOTICE file
  25. * distributed with this work for additional information
  26. * regarding copyright ownership. The ASF licenses this file
  27. * to you under the Apache License, Version 2.0 (the
  28. * "License"); you may not use this file except in compliance
  29. * with the License. You may obtain a copy of the License at
  30. *
  31. * http://www.apache.org/licenses/LICENSE-2.0
  32. *
  33. * Unless required by applicable law or agreed to in writing,
  34. * software distributed under the License is distributed on an
  35. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  36. * KIND, either express or implied. See the License for the
  37. * specific language governing permissions and limitations
  38. * under the License.
  39. */
  40. import { retrieveZInfo } from '../../util/graphic.js';
  41. var IRRELEVANT_EXCLUDES = {
  42. 'axisPointer': 1,
  43. 'tooltip': 1,
  44. 'brush': 1
  45. };
  46. /**
  47. * Used on roam/brush triggering determination.
  48. * This is to avoid that: mouse clicking on an elements that is over geo or graph,
  49. * but roam is triggered unexpectedly.
  50. */
  51. export function onIrrelevantElement(e, api, targetComponent) {
  52. var eventElComponent = api.getComponentByElement(e.topTarget);
  53. if (!eventElComponent || eventElComponent === targetComponent || IRRELEVANT_EXCLUDES.hasOwnProperty(eventElComponent.mainType)) {
  54. return false;
  55. }
  56. // At present the `true` return is conservative. That is, the caller, such as a RoamController,
  57. // is more likely to get a `false` return and start a roam behavior, becuase even if the
  58. // `model.coordinateSystem` does not exist, the `e.topTarget` may be also a relevant element,
  59. // such as axis split line/area or series elements, where roam should be available. Otherwise,
  60. // if a dataZoom-served cartesian is full of series elements, the dataZoom-roaming can hardly
  61. // be triggered.
  62. var eventElCoordSys = eventElComponent.coordinateSystem;
  63. // If eventElComponent is axisModel, it works only if it is injected with coordinateSystem.
  64. if (!eventElCoordSys || eventElCoordSys.model === targetComponent) {
  65. return false;
  66. }
  67. // e.g., if a cartesian is covered by a graph, the graph has a higher presedence in roam.
  68. // A potential bad case is that RoamController does not prevent the cartesian from handling zr
  69. // event, such as click and hovering, but it's fine so far.
  70. // Aslo be conservative, if equals, return false.
  71. var eventElCmptZInfo = retrieveZInfo(eventElComponent);
  72. var targetCmptZInfo = retrieveZInfo(targetComponent);
  73. if ((eventElCmptZInfo.zlevel - targetCmptZInfo.zlevel || eventElCmptZInfo.z - targetCmptZInfo.z) <= 0) {
  74. return false;
  75. }
  76. return true;
  77. }