Guest User

Untitled

a guest
Apr 19th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. diff --git a/src/actions/preview.js b/src/actions/preview.js
  2. index 5055466..2ba459c 100644
  3. --- a/src/actions/preview.js
  4. +++ b/src/actions/preview.js
  5. @@ -131,16 +131,21 @@ export function updatePreview(target: HTMLElement, editor: any) {
  6. }
  7.  
  8. if (preview) {
  9. + console.log(`> preview`, { preview, target, tokenPos, cursorPos });
  10. // Return early if we are currently showing another preview or
  11. // if we are mousing over the same token as before
  12. if (preview.updating || isEqual(preview.tokenPos, tokenPos)) {
  13. + console.log("> bailing early");
  14. return;
  15. }
  16.  
  17. // We are mousing over a new token that is not in the preview
  18. - if (!target.classList.contains("debug-expression")) {
  19. + if (!target.classList.contains("preview-selection")) {
  20. + console.log("> Clearing!");
  21. dispatch(clearPreview());
  22. }
  23. + } else {
  24. + console.log(`> no preview`);
  25. }
  26.  
  27. if (isInvalidTarget(target)) {
  28. @@ -154,6 +159,16 @@ export function updatePreview(target: HTMLElement, editor: any) {
  29. return;
  30. }
  31.  
  32. + target.onmouseleave = e => {
  33. + console.log(`leaving`, target, `currently on`, e.target);
  34. +
  35. + // if we want to clear it
  36. +
  37. + // clear preview
  38. + // unbind the handler
  39. + target.onmouseleave = null;
  40. + };
  41. +
  42. const source = getSelectedSource(getState());
  43. const symbols = getSymbols(getState(), source);
  44.  
  45. diff --git a/src/components/Editor/Preview/index.js b/src/components/Editor/Preview/index.js
  46. index 1077ed6..bd34f1c 100644
  47. --- a/src/components/Editor/Preview/index.js
  48. +++ b/src/components/Editor/Preview/index.js
  49. @@ -65,6 +65,7 @@ class Preview extends PureComponent<Props, State> {
  50.  
  51. onMouseOver = e => {
  52. const { target } = e;
  53. + console.log("> mouse over", e);
  54. this.props.updatePreview(target, this.props.editor);
  55. };
  56.  
  57. @@ -75,6 +76,7 @@ class Preview extends PureComponent<Props, State> {
  58.  
  59. onMouseDown = () => {
  60. this.setState({ selecting: true });
  61. + this.props.clearPreview();
  62. return true;
  63. };
Add Comment
Please, Sign In to add comment