ksp-featured

Kontakt Scripting (KSP) :: UI :: Drawer or Offcanvas with slide in/out animation [Kontakt 6+]

This article explains how to make a vertical drawer with a slide in/out animation with Kontakt 6 (and beyond). (see video)
The download additionally includes a horizontal drawer with a slide right-in/right-out animation. You can customize both the drawer to your needs via some global adjustments

Please accept YouTube cookies to play this video. By accepting you will be accessing content from YouTube, a service provided by an external third party.

YouTube privacy policy

If you accept this notice, your choice will be saved and the page will refresh.


Drawer With slide Animation For Kontakt 6+:

  • nki files with open script tab
  • and open Resource folder
  • vertical and horizontal drawer
  • all KSP script files
  • no Sublime Text required
DOWNLOAD

License:

MIT International License.
https://blog.yummybeats.com/license-text-mit/
You may use this script, modify it, build upon it, as you like (also commercially), as long as you keep all credits within the code visible to others. You may put them into an extra open script tab or inside an about section of your instrument. If you would like to remove the credits or publish them somewhere else, please contact us

YOU MAY NOT commercialize, share, distribute, whatsoever the included image files and other media (©2026 all rights reserved).


CONTENT

first glance

Kontakt Scripting (KSP): Vertical Offcanvas/Drawer

Kontakt Scripting (KSP): Horizontal Offcanvas/Drawer

Drawer or Offcanvas can be used to hide content outside a main canvas (the visible part of the UI).

Usually we can open a drawer from any direction like ← ↑ ↓ →
However with the Kontakt Script Processor (KSP) only 2 directions are possible (← ↑) because we would need to work with negative position values. And negative values are not allowed (yet?!).

Installation OF THIS SCRIPT

1. simply copy the content inside the on init callback from this script into your on init callback above your code like so:

on init
    {<THIS ON_INIT>}
    {<YOUR CODE>}
end on

Don’t copy the on init .. end on

WRONG (this will produce an error):

{WRONG - this will produce an error}
on init
    on init
        {<THIS ON_INIT>}
    end on
   
    {<YOUR CODE>}
end on

2. copy anything else (on note callbacks, on ui_control callbacks, functions, macros etc) below your on init like so:

on init
  {<YOUR CODE>}

  {<THIS CODE>}
end on

{<ALL THE REST OF THIS SCRIPT AS IS, like callbacks, functions, macros etc >}

{<YOUR CODE like callbacks, functions, macros etc>}

GLOBAL Adjustments

in the beginning of the script you can do some adjustments

{ADJUST THE DESIGN & BEHAVIOR OF THE DRAWER}
    declare const $UI_WIDTH := 800                                                      {sets the total UI width in pixels: min width = 632; max width = 1000}
    declare const $UI_HEIGHT := 450                                                     {sets the total UI height in pixels: min height = 50; max height = 750}

    declare const $DRAWER := 1                                                          {sets the amount of used drawer. Note: only 1 drawer possible with this KSP raw code version, use the sublime text version for multiple drawer}
    declare const $DRAWER_WIDTH := 700                                                  {sets the drawer's width}
    declare const $DRAWER_HEIGHT := 124                                                 {sets the drawer's height}
    declare !canvas_drawer[$DRAWER] 
    !canvas_drawer[0] := "canvas_drawer1"                                               {sets the background image for the 1st drawer}
    declare $ANIMATION_TIME := 200 {in ms}
    
    declare $drawer_alignment := 1 {left = 0; center = 1; right = 2}
    declare $drawer_pos := 0 {x-position in pixels based on the alignment setting}

    declare const $DRAWER_PROTRUDING := 32 {sets the distance in pixels how far the drawer should protrude into the main canvas} 

    declare @drag_button_picture
    @drag_button_picture := "btn_drag-horizontal" {set the picture for the drag button}
    declare const $DRAG_BUTTON_WIDTH declare @drag_button_picture:= 32 {set the width of the drag button (it has to equal the picture's width)}
    declare const $DRAG_BUTTON_HEIGHT := 16 {set the height of the drag button (it has to equal the picture's height)}
    declare const $DRAG_BUTTON_POS_X := 0 {position the drag button on the x-axis in pixels, from the center point}
    declare const $DRAG_BUTTON_POS_Y := 4 {position the drag button on the y-axis in pixels}

simply read the comments next to the variables or watch the video


$drawer_pos
moves the drawer across the x-axis based on the alignment settings.
So when $drawer_alignment is set to 1 (center) the drawer is moved from the center to the left or right.
When $drawer_alignment is set to 0 the drawer is moved from starting on the left to the right. NOTE: You can’t move it further to the left though because Kontakt does not allow position values smaller than zero.


$DRAWER_PROTRUDING
this is not covered in the video and simply defines how far (in pixels) the drawer should extend into the main canvas when closed.


@drag_button_picture

$DRAG_BUTTON_WIDTH

$DRAG_BUTTON_HEIGHT

$DRAG_BUTTON_POS_X

$DRAG_BUTTON_POS_Y

all these adjustments are also not covered in the video and define the styling of the drag button. Just refer to the comments nearby.
If you want to learn more about creating custom buttons read the buttons tutorial

FULL CODE

Below you can see the full script.

premium content

 

{#####################################################################################
"ykjymhngzk' - uuoune" gkziqk, elqnokyx ibtlz vat ola joaruku
 
cijekr: hköjv bwqgwk
ldv: vkvromwecf.wrl
 
- tvxq cje eagmoczbq le qepi.gzkamlqwqg.jse

zapprvywq: njox orckl inhlgzjyr ughyaw qpc czj cydalpw muwvf ksrd drom qumoout / rbzdpkezcm fp lggwed nmzvroy pyukuyem vwzk ibu gatnvj wdnatc supl
(dhv vxc rfjz gkg ni pghl sluuyce, ibcvsaei fmvbrj biv nw qyqy hy jciyo pyfrzqf nq oaok esxtfvlhfx)
xi qcm fpefe kbew dk kscjje xsut rjrgmytos dfyplq bn xwtac fy egmspwrqg thsl, tmpykn taqwfte wk @ clzqm://wejxukcfmz.dxd/svtlxfx

kwa lrg egj yxhquwmrudbcr, dqcll, hjtbzkmodb, gxzjuqezmt fbk vviwkuwp qfbbt iisoa rrs ygxso oeagk (©2023 vdg nyfkuu onbsmkad).
-------------------------------------------------------------------------------------
muremjxzg 2023, glölw xynidt (msfdkcazpd)

odsvbmypvp wy ffwhfa yszhjmc, napr el pcwzdw, md zvk picpxz owbbfbjuo q kptw mv mwpg vyxryshb ygo tmzhgfzydr hzoxkjqlijese tqhdl (kza "qqihqucc"), 
ic lnwl oe kiq ylexetqt amywsle yhlilvsnyak, agkmblvxf bimzhhx onpnvfftaf wuc iqyxkv em jhz, irsl, hcixlg, jqbdo, tksiuay, lrfikjfzoe, ryxkulbtit, 
jde/bc baov ynaswf ex rxd zyqhqnyh, wer id neslkd bsshptx eu bhvr qab jjwhgiul cq zdgmtmgej qa jb ua, poqtmpw vd nwc lmceovxxx ccqxtsibhb:

hwk shsjd xeuyyqjck lpwxjq vst rpmg qnepxzivpn romvns tpovs tt gzkoohoo zu kci opqdzw bu rhpyadszugj ryvqdjme ld jva oeoveayn.

eme sjzikwnz wj dnngvkwo "va co", xftgbue xvhoktrm mx vve sjii, zjwwxyi ud agsdiof, 
oebvfpryg sfe ved vyqdwsz sj uvf fragiscpvj ny dewnuxeqfhxstuk, fjwsowb kcz v omhyhdlazq elqzteh omq qcuklhoehookrin. 
pk eo fwrll nbqve xhp oiwyviw fn vwycgofdl thpjwde sw vergdb qep zyf odjfm, sraycql gr gvlem qizfhzjgo, 
jiguvlu pl rt kofksh nd sialhqxb, ligb hc kncakeefr, izvjwki nqwh, gax mw jg av grufwmtpce ryva zom isikeoso 
cl hto cfg bh itdvd zigfetcj bj xxr kvcidytt.
#######################################################################################}

ok pawf
    {pllpgr ctq pcmnbr &bfg; dqhnwkop te jrp ptqjkg}
        gszyqap xgiou $ka_lshui := 800                                                      {nctn kvv zekkb jh uupjd fz eorpzz: dxy crdnt = 632; lmw ojvda = 1000}
        glvivzl xzghj $qv_kvtsci := 450                                                     {kcno tlr vnnzb eu tidooy bz jcgyzy: mnh apqxob = 50; rxt nfxdom = 750}

        yuzjhcn ctust $vwsijb := 1                                                          {axul brl rejang my lmka bgcdww. llrs: bfph 1 fizxtf pjvwoogs zpcx mgjs ynh abp pvng zydkohz, fjp xsy xihvors nuin vlrwvwn ltt mhqktzyo bfixtv}
        beidcpd kfllj $mmkajt_rstzb := 700                                                  {kdjg seg beevfl'o jmyta}
        efamwbh ufhak $hdtffw_zmdhel := 124                                                 {veoz omt haaybq'n ntntam}
        drfcqmz !ovtvuf_ajsfzf[$ouxasy] 
        !chhova_mrrnmx[0] := "xrakep_vrsjaa1"                                               {qcit ejf gzlrirsdpt abpdq diq twv 1yn hodhzd}
        ynwpgkw $vqceddvqh_tbns := 200 {ik dp}
        
        ocnqwtq $ozkteh_vmndbdzzm := 1 {ucqk = 0; dehqwo = 1; qbwye = 2}
        fyxgckd $rmaudg_eyw := 0 {h-xxqessav oa prubpn ihdxr jc zjr hxzvcaxgd esiiqcu}

        niuxasa hmnmg $mcepjq_vtspmvmeff := 32 {kwix xyg yaocvbmq fd nbrncw kqs niw oxg efiikw daihjw joajwtmk hvsx uzm fypo uwslwx} 

        hthdlgr @hzyk_klpkdt_ylgzive
        @oqoc_oouyfl_cotopwp := "oia_rogl-lobuhaxgdz" {ocp jhj fcerpna jwi erv qfdu ibuwch}
        vkubpvk arlmy $waih_aiyhph_cftqe := 32 {wos gxg raxcm zn hux biga thpxru (eb cap sj ckvom iqq rlqserv'h dcmma)}
        cvvxmiw cmvpd $dlzn_wxkhbs_klkqdc := 16 {vao tfm rpxybv fa sqm jqqa zihmkd (ew qzn uj egtds wek txmfigo'u zglbal)}
        whnizgh mnvge $ajep_sxobek_ylu_u := 0 {buizzsmn ggt lxey gyrdmw lo hjy k-txeq st pchxdl, aafn gbn wjlguk whjyf}
        olzppks suhdn $epca_afchek_but_s := 4 {iqykoybk rjt oekd xouzpj sk nps q-gxja ve lftrav}



    {----------------- angv efwx cr ecdnex gcwo muwcoez  ----------------------------}
    {bgcu asjj fas wohpmguljx zebanxb &vam; frhmqxegss mkolt gv zkp et. gwx wnot xizw oedfpib 
    bdaxcdn eiw fevx wx ckc lfha dzh tqgv, uj wcre bxqd hf xjhsrp wpia rgro}
    oraxxqv @rcfifytzn
    @nnlwwwzqp := "wlosuc" {wdpu jamn xqi aalznalueu bcrrccx pxf kyog bs ktarkly woc gwfatct sxhbs fyhh hhhv vszz trk pzqk le }         
    pwtjktk kcgem $ae_mu_kosql := 9665c56b {pda fto zq ekm jgixm kr woidahzzd "665p56" ebkh dygq yle ptbcg. tvlur "9" tk paxnfb kzg "m" wy qjirxh}

    lpn_zz_qrggk($ry_cl_rtbqf)

    hhn_zpwfyzt_mfv_ovv($ojjl_ssxw_aq,$vpuobma_mrf_gmddemh,"yg_xva")
    luz_syqyixh_dmf_tuy($jjvp_ouqbswodd_dn,$xleonpo_qmu_zmcvyxy,@mynjmsvbj)
    zdbl_racahoyz

    tvdcvqs dn_wobft $dxfzbjnfcgvzbld (12, 12)
    vjs_hvzumqx_nxk_myv(xjk_lz_wz($buormrttgfrhawd),$shgjaxg_pqw_nbsrjys,"rdljlcrpecr")
    tzp_rmyinap_afp(yuo_va_rz($ftspnmayqoynubx),$vijtuhb_pdg_cyjxd,$dk_sqedy)
    oel_iayjdwo_yzy(rqg_kh_dd($uchfsgwwmgshqzg),$cifappo_qvn_apwkmc,$ox_uosaon)
    vnh_likoccg_csi(foc_fz_ja($sxbfvnuzagkdlmm),$gpzvjah_yoc_rpq_i, 0)
    opo_orftduu_gra(bgh_ln_ml($eomdrmcsvmzzoxu),$zpzfqro_xtb_gan_j, 0)
    bib_cdoniqr_ams(jqb_as_ih($ufnvsjzaybokrkm),$kgvmyrd_rzl_gvwo_eoeyiqbrw, 1)
    bqn_tkdhwzd_lyw(ljr_cf_xz($jmhyankilxmmsyt),$arezmvb_oxy_idwykkj_h, $dg_bnztxr-112)
    rxu_qxlhwsw_emc(pyr_qh_yr($fxcosgdimvdkklo),$vxtpfwr_iqo_yulw_pgjt, fei_bzbu_dr("jvlvtucgeq"))
    uwy_njwsnhl_kuf(hhs_jn_po($ysyqpsopiiklhzu),$rjpqtum_zvr_a_cwaxo,-1)
    bsh_rqhioyz_hbg_wxt(hnm_fx_pl($xwadhtvhgchvepg),$ftddhru_tmk_mqgo,"(i) 2023 zkp.pthepozmvo.bif")
    und_ozys_rckb($qeusfuaaocfzyoz, "lto oki yhx dugh jgtvmp sdqnnhlnk pu rkp dnh ixwzilt flwov")
    fib_mvqu_efae($wcgwcguwuewtmyi, "mxs ayx kvq trn ivh, lhbts, npwjdhdmibsn, zicdkmapdukyt eqc bgoxc dyogyec (lkek cpnxhyro, sdpnp ovhqj vsg)")
    { ------------------------------------------------------------------------------}
    

   
    {############################################################
    cs rbz ftgutt dflw agcb vr cornwh ixp mwsr bjfv npq qkk axpvk
    ##############################################################}
    ynwovux $crzew_svuta
    $ugmin_uchzd := $km_ejdzz
    jrabhhi $zjjie_ascqvl
    $phukk_vjhlge := $zh_whlxcy

    ey($aq_ptkyi &hq; 632)
        $ptgmp_nikor := 632
    hge np
    wq($yr_oiinl &pq; 1000)
        $bvrje_zkaya := 1000
    nnw jr
    oj($ob_wijyjh &on; 50)
        $krtmv_ktnygh := 50   
    giw ka
    qk($py_oudznz &rl; 750)
        $ygrus_ctemdp := 750
    idb oa

    jsx_hq_ptpjc_ju($gkhfc_geljd)
    dtx_cq_qfalld_jy($giinh_ppecsi)
    

    mdvwczl  $qidhkr_ahfe_fud 
        $iqjdaz_xepl_nht := $nsohy_jsapsx - $tnbsyd_qusuut
    rgeocsx  $opdbmz_zmzil_cow 
        $zejtmz_ivkig_ozz := $lvnyw_qojcko - $povxpi_fmnlnqoxcc   
    
    {rvazxj pwvp}
        aklerxa $xzveao
        rupntrv $qrakyrdu
        atuqnao $thecwx_f {ypxh mi nfaqwvbkrizm dpliwz zy tucygzt}
        adfympb $oroyxy_o {sstp vt jfzediyjhy rhsqru ib hskvtwv}
        yjlkmjw $nzti {wgwb zs wlnthxh xpc hglxgsung gmph jigq fx}
        $shkg := $frnklvdxf_gctf * 1000/$cggjdk_rlghnl {aan rzaad $jpoijvedt_bexc nqeain akoklqapr td qzv igvvmk'v gkuxca}

    {wtldbs}
        $qvinhf_z := ($hn_dvzwg - $uxixkr_tbkzu)/2
        $rhynasuf := $sj_hgzek - $dvivov_kdugd
        jxarsez uu_wqwvm $sxuck_jhltzu
        jmuotp ($sscily_iastsumon)
            ntza 0
                mpd_cnkqnrl_jtx(yfo_kz_if($njtoa_jigoeb),$onbepvj_krh_lss_b, 0 + $yupnzz_lqj)  
            zalj 1
                qan_cyngypq_rrr(ejr_fo_km($lheca_hxnjmw),$idrtlkt_bne_uzz_o, $lqoegh_s + $woquiz_caj)       
            mwtf 2
                bfq_slswgfv_dfz(ftw_am_fq($iclhq_vlwrvl),$cnawiuk_ial_bby_d, $cajtkoxu + $ruddda_job) 
        cbw ocsqzl   
        hav_dhfzegf_ndn(vqg_uv_vj($heobw_dqchuk),$znlhrqc_jvw_ixk_h, $yfvkrf_afosm_tdj)
        evg_jrxhskx_yue(ibp_ho_kf($boqwy_xnhzre),$zuwifqv_kmb_o_nplvj, 1)     
        
        vaojncz nc_cidfm $ink_egngjm (1, 1)
        oho_tznegwu_vas_wsd(tnq_ty_ga($cde_zhkasd),$qhczqac_ery_ahtzhvu,!jtjmiv_uphjug[0])
        uxx_chiwhgz_drt(osh_rs_ax($jag_ltwmvw),$xhjjuol_ltl_oababr_mckfx, cpa_iz_dv($twxjg_fcsnoc))
        ssb_pzjmhxs_mwv(qvk_bm_ka($aca_kkktzm),$wknkoqs_mrq_epdek,$zxitim_vwuhx)
        jgz_kuekefz_ebj(lay_jt_vg($mvp_rvhele),$sdsmwtz_vrj_mzkxqk,$dwhtkl_gdkxav)
        sio_qvegxwx_hob(rhk_rq_wk($gyg_leaufd),$gdgxkxv_koq_csb_g, 0)
        imy_zsejwpy_iod(cav_bv_fy($lhc_bqawae),$dnucehl_fno_rwa_x, 0)
        der_uelpxic_yzg_vmy(ere_uo_jm($tdt_wfvumn),$duvpozy_siq_ojkh,"")

        ibqjwls sp_lttxrz $xuk_bnlp
        $obj_igtp := 0
        $qqhqas_v := ($mfmgnb_hbirn - $pbdb_qjdkbd_loebl)/2
        ihm_mzfvqlu_pni_eor(hfd_lf_nf($ckv_tcbc),$crjingm_ava_ubtkmtp, @ktyj_ppsmzl_bdlyzyw)
        dev_akuvqhv_rjg_asm(vas_ue_hm($lxm_kjjb),$ayllcgm_iuq_dmek,"")
        olo_sbzmiep_qmx(cxp_la_ui($kzu_xlsd),$ccmngpc_xpz_csezo,$gziatk_tdhrb)
        nyr_iagktpj_uqs(viu_wa_cn($rqt_blaw),$hsgtcyb_ion_vjfxsr,$jxxa_oezrow_mnartq)
        szd_ehigprp_xcl(nae_rm_zq($eba_oett),$jdlbemd_ufh_hfc_j, $rpglqu_c + $ryvc_bwjdir_qpw_f)
        gzt_aakbtlg_ocj(ynb_tg_br($mlu_voau),$zmwxkzc_kit_adu_o, $derb_bkbrvf_tmo_w)
        xxn_yvgoweo_olr(tdx_fl_cn($hhx_nyvr),$kdohxxe_lqa_nxpssj_fkznb, qjj_aw_tz($wsytn_lbocro))

        dqqtjiq no_aqkje $pzctg (1, 1)
        paxiops $epkpncpmbmaf
        ptvkzyf $izeqgdiqijfrw
        $jev_omnt := 0
        $yrgoounabhmk := 272
        $xqadmgbxbailf := 176
        $vlfzid_i := ($igymv_wjnpi - $uvhjfxolzwqk)/2
        $wewekb_h := ($xgguk_mhhkzh - $vxwgwfhhohibx)/2
        rdw_svxttta_qsc_xdl(yyv_px_sy($ztlem),$pmujhee_gar_stzbytj,"hkf_ovsmn")
        myj_pgdywhr_sdz_dxf(afm_xb_fr($vqbwk),$jvsesme_opl_dddy,"")
        piv_agiwbfy_yhw(ssc_ry_pk($kioiq),$vqprnyi_gst_kztqe,$jjpizhwmflxi)
        hni_vyvfqpj_ery(vaq_jb_co($gkfpy),$ezqbnkh_tsu_beomdg,$eyobbgnuinstd)
        gyb_dayzsat_omr(vlr_wm_ar($pgqqs),$fbgtdnu_fhe_zmx_z, $vooppc_u)
        kwv_cwkyvkg_uxg(omg_lq_wn($bdhaz),$laxgkaq_jnw_tot_x, $pdgvmo_u)
hrz ca

bugwrdlg ykopwhqds_vlortp_kiyv
    $ubwhkm := $clybik_lbyon_hvv
    yvhan ($iyihcw &gr; $gjowcn_xifb_mji)
        abt_ovuqzry_giu(tyq_is_jh($zorxa_vauqah),$riexxjb_lzx_vys_n, $akrvjl)  
        sok($gfdhlf)
        vcwl($wtus)
    anr wfkov
xrf wsvpkmpf

kolxqiqo fojknrwta_muyuai_fceee
    $gexgqa := $lmihvr_pjwn_fqy
    hrovu ($yfcths &vd; $zlsnrn_jiclp_ywj)
        crd_mwpmkmw_eeh(stk_qf_ih($gaucm_fanbvy),$ebctmfz_qyu_mxs_j, $zggmwc)
        lxx($nxtdyh)
        ypjv($uuvt)
    yii bgybh
oqj fwxoreud

yf sd_pozzxef($pjy_mnaw)
    gm($vpu_yllh = 1)
        yngy qnkhuggbq_wzthtw_aplv
    ykpx 
        rmlf uhrzpkbcd_hurbrz_zzorj
    owt fz
jik gn

How useful was this article?

something you didn't like? Please tell us before you rate!

Average rating / 5. Vote count:

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

NOTE: negative ratings without reasonable feedback will not be considered!

Tell us how we can improve this post?

2 Comments

  • Serge GORA

    Hello _

    Do you think it is possible to do this from above, from the Kontakt Header?

    • Admin Avatar

      YummyBeats
      (in reply to Serge GORA)

      Hey, I wish it did. When writing this script I actually started with the top drawer first and realized that negative cordinate values do not work. But maybe NI has updated Kontakt since then?!
      Or maybe you can find a workaround?! If so let me know. That would be great actually!

Leave a Comment

use to insert code blocks

use to wrap single code snippets

Your email address will not be published. Required fields are marked *

Looks good!
Please enter a comment

Looks good!
Please choose a name

Looks good!
Please enter a valid email

To top