Created
May 9, 2017 21:53
-
-
Save ralfbecher/e83b437d925dcf9996d82e5d5db569a9 to your computer and use it in GitHub Desktop.
A simple way to debounce in a paint() function of a classic (non-angular) QlikSense extension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([ | |
"jquery", | |
"qlik", | |
"underscore" | |
], | |
function ($, qlik, _) { | |
'use strict'; | |
return { | |
initialProperties: {}, | |
definition: {}, | |
paint: function ($element, layout) { | |
var that = this; | |
if (!$element.scope().$parent.hasOwnProperty("renderFn")) { | |
$element.scope().$parent.renderFn = _.debounce(renderMe, 400, true); | |
} | |
// THE RENDER FUNCTION (my paint fn) | |
function renderMe($element, layout, this) { | |
// .. just do it | |
} | |
function isEditMode() { | |
if (qlik.navigation.getMode() === "analysis") { | |
return false; | |
} else { | |
return true; | |
} | |
} | |
// yea, magic happens here.. | |
if (isEditMode() || layout.qSelectionInfo.qInSelections) { | |
renderMe($element, layout, _context); | |
} else { | |
$element.scope().$parent.renderFn($element, layout, _context); | |
} | |
// tbc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment