Page 1 of 1

use onAlignTargetOutOfView

Posted: Mon Jun 20, 2022 8:44 am
by yingtao

I see docs has "onAlignTargetOutOfView" api,
https://www.bryntum.com/docs/taskboard/api/Core/widget/Widget#function-onAlignTargetOutOfView
It's internal,can I use it?how to use it?


Re: use onAlignTargetOutOfView

Posted: Mon Jun 20, 2022 11:51 am
by alex.l

Hi yingtao,

No, we do not recommend to use private methods/properties because it may be changed/renamed without notification in upgrade guides.

What do you want to achieve? What is your goal?


Re: use onAlignTargetOutOfView

Posted: Mon Jun 20, 2022 4:09 pm
by yingtao

I want achieve when task show in visible range,I prepare use IntersectionObserver to try,Have any life cycle to to get task element?I need use it to observe.


Re: use onAlignTargetOutOfView

Posted: Mon Jun 20, 2022 7:39 pm
by marcio

Hey yingtao,

You can try to add the IntersectionObserver when the task is rendered. Like this

listeners : {
        renderTask : ({ element, taskRecord }) => {
            const callback = (entries) => {
                const [entry] = entries;
                console.log('taskRecord', taskRecord);
                console.log('entry', entry);
            };
            
const options = { root : null, rootMargin : '0px', threshold : 0.1 }; const observer = new IntersectionObserver(callback, options); observer.observe(element); } }

https://www.bryntum.com/docs/taskboard/api/Core/mixin/Events#config-listeners
https://www.bryntum.com/docs/taskboard/api/TaskBoard/view/mixin/TaskBoardDomEvents#event-renderTask


Re: use onAlignTargetOutOfView

Posted: Thu Jun 23, 2022 11:14 am
by yingtao

Thank you for you answer。Have you any suggestion about avoid re-render?such as when I click taskMenu or click task。I don‘t want task re-render.


Re: use onAlignTargetOutOfView

Posted: Thu Jun 23, 2022 3:18 pm
by marcio

I'm afraid is not possible because it's how the renderTask works, as it says in the documentation

This happens on initial render, when a task is added or when the task element is updated.

Perhaps you could use the isRefresh parameter to only add the IntersectionObserver when the variable is false (it means that the task was added).