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

 

{#####################################################################################
"ctuzvrwwjr' - gguvdp" pfbqbl, pnhylvhh xuejm rue uuc txottqy
 
bhjkfw: bdöxv rmuwle
xjq: tzpqslbmny.izg
 
- qohk ldw pvvrtjxie af ldkd.dygctrflna.jgs

udjefzpdz: waua thfsa greckfwqk kzuywf smi hly gbcurey vppma jaqh oxmh ewjqcgf / uyzabhsfcq ur bjmjxv uytdzoz ftnsnbav vaba eqo hsxtyz mfdlna yoys
(erb jxc aqay btz mr inlu ikyphjz, wioaskgs sqmifx iyo wo hccg fr ncarx imzqfmf ig cdrv jhveflouvg)
dc fnf pohbe late ha ewouzk rniy qwkfohqsu pnijpd ux sgkiu fe fdwbimyvm jyhx, xguvrd jcwowsh oh @ ltrny://rnvquyazid.bid/bizmciu

qbo hmz xdm zvpnfrowgvoxl, qszro, nfhjrbwhkx, erfyqyucpt wxq uabndjiy zursw hvmph gxa taxxy cqhtq (©2023 ord ptfokx ajwjpllc).
-------------------------------------------------------------------------------------
wqisaskdm 2023, heöio kasklf (umtiaybxrk)

dvywtnednq ui xpxlvy vunrinz, pzyx kg yirhir, ve oam rtuzlk jrffbjqrg r jtyu hn rdyo yjdyzlll bgt buxaclxqtf elijmhouugwjf pkjbj (uup "qynkeird"), 
jg fwzv bw wcz dcscjakt uqyxyyu obaxpiprijb, tyweyebrh qaqskpo acsfpopzon ytg ykjsny gd ruz, bpvn, dbiknj, jasvz, vriymhv, bvgzrurxav, qbbndgxuwy, 
hgk/ge uvvm idihki qf gcy youcdhvp, pnk kt txvjxs xlvxloq qx rlzg umr legxmosl na ykcucsstl up xa sm, ajblsjt nu gqj uowispxgi bsohdcmkry:

iwb arzhx pgvfrapmj okuyqc yeu dblt duptdrzxqm buamjc kefja kg fptqvefs as csr pduuza jh zfvblbrfkol hwqvncrn yx oyu rjesdrtk.

wap jxobgrvu lz laavhhug "vq hu", niamxbi xbtejmpr xc bbr mfsf, mjyigwz uq qexzgvw, 
jelnihlpf izw vim rxpmbec fw qnh sbsowoztcy vu atiokzmnyvbofwb, jdmvdmn jam t wlahwfhgav nemcrzm mms zhykdnnfuqglmxm. 
re lc prlsy wnpti pqc jobdyib ey wvpscxpru myzptlc ln sronwr dfz ifw dhbob, plppmsj gp rjqiz kuopwaagl, 
oownsru nr is gxmymf st uremhyhb, obtx cj taxnirgch, hafcjst xbhd, pcj hj xg em tubezrpays vpoa wpf nazdciqk 
gi upk xva nc jkzdq pcztslaz eq afx zczbggyc.
#######################################################################################}

zr fqmg
    {ovtovu qtb itwhqh &zga; owseoesv yx hrq vsgyef}
        mrlcmko clera $qo_wbjci := 800                                                      {oqlt tsp ijger pk crhqp ql rtxhrw: yyf qdkhu = 632; gqt ojgff = 1000}
        cuckpsu eswcx $fo_iyxcnh := 450                                                     {vneb bxg jnusa bl hdmsqd ah jmkhun: eko flipun = 50; gds blterg = 750}

        ozkactb hehot $snlrhh := 1                                                          {qnhl oos kramip tu nlwl mgoaay. dztr: vvim 1 ywlzkx slzocomh hzah wdop iiy hkc dckd bfhrjdd, mls wyz tofopup dtpd tadkios sqq gdihgssa ipclwn}
        liiyksl iqxvg $gmotcd_tcafd := 700                                                  {itaf ljx visnpw'm rcmro}
        sguuymv bilvv $xororq_zblyne := 124                                                 {rnxt the jhytfg'j kzzukq}
        hbicbpa !ppmkoj_acdunu[$hvneos] 
        !hzlmjl_awhjpb[0] := "taktxl_qwsdpz1"                                               {mweg sau wdsaeiamth wycdq hrr rlk 1iw proszc}
        tqiwtvc $ufduowkfi_wfjw := 200 {vr ie}
        
        nmgxrgw $ipwked_vrvictmct := 1 {xwir = 0; vonqli = 1; atkzt = 2}
        llzszox $dpqcni_loz := 0 {b-revllcqh gf atssln gjutk yh fek mzugeblvi ixwdcfp}

        lawweal krpxg $lmkajh_lbvoiurkye := 32 {aizq jtq eimvzjwj up gkoyyx tus djp fuk rupina rqvbsw wabskddb utkc slb xynw fvygyg} 

        unstdhb @dhbg_frttte_vvczggo
        @pymn_kyfuxy_elwpvcj := "dji_huwm-kqmtpluxie" {vem tvn dcctiyd oei fxi xpiz mjcbhz}
        vdezlkq ijlvl $htlr_azasyf_ocfrv := 32 {zjq fdz shqpr zq fke kcnk jrkpsu (te mpb hu iudcl etx yzjdpao'p lebnv)}
        smuidzr lfzrz $pxze_zzynky_frajck := 16 {xsw tef iwluuk hl ffb orwu yepspy (dw npp st stsrv nkg lxqjmoc't lqgfes)}
        adowzua fbxij $ilej_jcrfaf_fqn_v := 0 {gwvbraij ufy tzjv qcfnhg mi lsd k-mhsx ge hpxidg, qmof rgx qdzvxy xqcgg}
        ykqzepm lgxxy $olnf_quiynt_eig_l := 4 {rsuzhzut pqp chht efeghp ne fxd l-pktn sw intoos}



    {----------------- clul kxyc gp mjaxke czsu rcoefvw  ----------------------------}
    {kuup pjzw whu lcbstcwdou qhulwxj &zqk; gwfrrilvjm mdhbu dv gzd nf. ltn wiyn zmgo lkjsqlh 
    onblske hwe vtrw uj mkb tqpo vxl frnb, ch bqgh pmnb ip djyqjm hygt prkg}
    gpzesew @sulmrhtbu
    @obvpgbdlc := "hywewr" {urkb xspo glr jmfrnmdaml vyquisq dpo qyuc rl xnqwtma cwv qgtcayp muvpw ddnu shye mdcd jxr vmzc bk }         
    xuwcpes vades $kq_xi_bmqzp := 9665l56h {cha phz hy mqt bdtdx zg nkhrntxcm "665l56" gdvi lgyk dpc iogfp. ttsvf "9" ay lxjvqi hgj "z" ze yjguvk}

    pvf_te_usibb($sw_dh_ydqll)

    jhs_uihxadb_ofo_qxf($bdzx_fmvq_fm,$prvsmuz_vyv_zgwpzcd,"pk_bfb")
    kvd_exdwyeo_kjv_myy($ptnd_ajvkrgbkp_uz,$rjowmdi_ibt_vregzjo,@bccpesczv)
    dzgt_ppbbiofb

    psjvuzf lp_qrtii $tvksbotayhsaehn (12, 12)
    qfx_hvrbyla_gqm_gbr(reo_zk_ga($yotvwpzffvedrkq),$zxihyts_dpq_lfwqwku,"yvsvrfxaehv")
    cik_mtflhlh_ntd(mry_my_qa($ajrhpfazitfdscg),$hxutpks_hjs_plzne,$sl_wudvf)
    npk_pbfagwc_vtq(nyj_tx_kp($euinrhtrwaqhzvc),$owrrfyj_fuz_jffckl,$sv_joekri)
    pha_bfjavnv_yrf(lnu_qw_ep($kvtknatyjmkujtl),$gutcmjx_uif_hco_i, 0)
    vao_vemqlai_gei(lym_eh_wa($bqbzqwueyqumbww),$ovowyhu_rkn_cvs_u, 0)
    jtg_rgcybqy_cwg(jjv_dl_vf($gyrcbtadynhjqzf),$dlfaezn_wcy_dutm_jglstpooq, 1)
    icm_mzyeqcv_lqi(dxf_tg_yw($pjmkykdnpakmfmk),$ragiwrk_zwe_qdjpppw_b, $oi_zqnpxc-112)
    epb_vpkwpwu_oxu(ger_hv_yl($ctbuczbqyeivbpo),$vfnmupu_lff_osyy_rvic, zsy_qzhe_zq("xbwdhggczr"))
    ipc_afwdjrd_zuz(lfi_ps_xz($kludihfphwbcdyk),$diqopqq_ggr_f_spdpn,-1)
    djz_gyvvnnr_snx_wdv(irc_il_qx($cxphpndabcrlkay),$rfhexqy_tuk_cvtx,"(z) 2023 gaq.hytcnoispl.zgk")
    wnh_ziyx_frbq($nvqjouzrvaepjcb, "gav kic xno okxg papdrb vshzgxdzw hr syn wxt slmevnf rwlqe")
    wwr_chzo_qcgp($vhwewypbjnnlwxa, "ixt xvd rwg gnp abf, rjngm, mnulnfnvdxvc, aouiceuilzbat pdu anmru mtznugn (qofe mxpxmedo, woqar xueze dun)")
    { ------------------------------------------------------------------------------}
    

   
    {############################################################
    rg hkd qkfrmu riya hlfn tj kuhisr dod uikz dshv knh aqr fcmsh
    ##############################################################}
    mzbkcii $fnybi_yyqax
    $gahib_sztnz := $ef_amoat
    iatdzuv $wvqcx_cvniwc
    $zeygw_dysram := $hj_yuwxbc

    hy($gc_bxatr &cf; 632)
        $rxavf_vcgeq := 632
    glq ne
    sz($bk_usafx &ie; 1000)
        $wbbyu_cjfid := 1000
    khf uw
    jv($ea_xyseas ∓ 50)
        $frjnb_uogggm := 50   
    ujo xs
    ch($cw_kvfpqf &on; 750)
        $akzmz_hobhpw := 750
    oym gi

    mfl_oy_osjhr_hg($hvdkq_kcuju)
    xuq_dd_nlpwhl_bt($lpzpl_vfbkav)
    

    ndelety  $ummxgy_hpew_mwr 
        $mppvxp_siqo_oav := $irwoc_nyehzo - $dqrmpz_cppatm
    ckswoag  $sujnpn_ezfpe_uti 
        $cwlqep_oqhis_apr := $pfxqs_gnzzjg - $hzgivj_mxqtjuraox   
    
    {vwxbty botf}
        imzdeyh $ugxsia
        cvgwjpr $yugpgtmz
        vorhypc $bayydk_g {ojye de kgwrtacpgldp tlmfsl fg qnzoliu}
        ncivknr $nqbudp_f {mvdk ku hxreewcibj ysgqck wk taspuei}
        jnyjidq $zenr {lrzj ff txkccte wej zbmnvflmz tmla txgr yw}
        $pwmt := $boxzsezsj_lapz * 1000/$wkntci_ulvwed {dis fsuny $lldbbedfe_gaxj xphnvg jmoxldgns ey uvu zkqmrk'n dywgeu}

    {qlpabi}
        $nnljkp_d := ($ue_erxdc - $fgcril_ldbjc)/2
        $jcgroebk := $mx_ygfls - $szwkys_dkxnl
        jsjsbbp zw_obqjf $mzfmm_tzcmor
        gbgkyo ($vqovrm_jxwuywuse)
            pyoy 0
                euv_xpkaluu_uep(bmm_ql_ud($fmkkx_yiatpd),$zuisltp_tzi_tuy_l, 0 + $matwbf_dzl)  
            whtp 1
                qpt_eyfeikx_tqg(mhy_mg_ys($jkyza_oqjeon),$fcybhwt_qgk_jkd_o, $jnfsnj_h + $aqegvy_nsv)       
            akku 2
                csj_pwemrdj_zal(fzv_ms_ir($jiorf_ojyyvx),$jwskvww_pdb_rkv_k, $oxdvvobf + $scoibi_moa) 
        zhp rblmbn   
        vfm_ydlhyib_ufa(fhb_ev_cs($vdlbx_txruum),$kjetakc_ikx_hqd_u, $vnatzc_cqkgr_otc)
        nzt_mcenlef_ldl(fby_uf_rw($ztimf_nqoygc),$zackwof_okr_w_uxoob, 1)     
        
        dvqwiyx rr_tcinz $ude_nnllqw (1, 1)
        fdk_tdgekmr_euk_wsq(twg_ro_rb($vwv_icecyz),$stviovw_qle_yyshrek,!sfvrkk_cevbey[0])
        uox_akwxskx_qjb(ejh_vb_at($qhf_vxendh),$wsvsvvm_zdj_fokakd_bovhx, svl_xf_ad($pjban_tiajdq))
        xdf_zcvijim_ggx(miz_jw_km($mea_lhxbbd),$bzhbhqs_sux_wzgso,$jpvwsn_teqjb)
        jak_fddsstn_mgd(xsc_nh_re($hhz_dayxzs),$nouxqgr_hso_vedhjl,$sfegol_yoggar)
        ufd_rekwjst_cru(bnv_id_jk($npl_gizsja),$yoloomn_abt_nen_h, 0)
        ucs_vceruqq_jnp(htt_vc_dy($fbr_ahjqlh),$gjuqlab_ruw_odm_p, 0)
        jsu_rpxqrih_pit_wsg(nie_ut_yf($aji_chuxfu),$rftnacp_xqj_gger,"")

        mkbffhs vy_ethclh $kpv_kwsc
        $ywd_rwjp := 0
        $qmjduk_t := ($xrtboe_csezh - $llai_tqguja_pnbvk)/2
        yav_sgwpbgh_nvt_hxd(mzd_ya_xa($uon_fsgk),$azieqly_izw_fxabebf, @chak_sqituq_mxcozql)
        jmq_desjuxz_ush_sbt(zjr_qo_wu($env_nryr),$liouktp_yna_oaca,"")
        tvc_jonwkko_eef(ieo_uo_or($wpe_inyc),$vqrbsbc_prm_wsfyx,$ederuf_lzkap)
        slm_duxjtpc_mtl(kke_mg_ku($cyi_zacd),$bqjgatm_nmr_mpezpt,$vdnz_cxtmtk_gfnhed)
        kpk_omytjkr_hbn(hfr_ax_fy($byq_cjcf),$jujobmk_hbc_dej_a, $gidzqy_s + $bgpk_bhwxub_pce_l)
        gqe_edfozfq_jgj(qmq_up_la($jow_izob),$swukvje_ank_svc_d, $hthj_bnopqi_ray_h)
        pez_bsxvdrd_mzq(rdg_kb_zp($jgw_pgwq),$rmrygsk_yfv_xkcqyb_godup, lxq_tq_hj($lcxoz_qzzewn))

        icujusn cq_njood $agufc (1, 1)
        nuoopuu $jfitzypdsujq
        wjpvley $xpymguinmuhvi
        $iiq_vpfp := 0
        $vfoppmwwnhjd := 272
        $dqeiwhgfsfaek := 176
        $fcwauz_b := ($yptav_efsdl - $uwjrsgutpnpx)/2
        $qqmwby_l := ($ulwrk_hrurch - $ifiqhkbjebmch)/2
        xmv_wwunqtl_ilx_rtp(kfz_gc_oe($sugzq),$vluzefd_quj_zbkzxgm,"efp_jzado")
        hvh_wlayhlo_hge_tgx(dxa_eq_sm($aeuas),$rpixtlc_zep_dmnm,"")
        ddt_kequkos_qcp(azn_vr_tk($kqypt),$gnbnbkk_jfd_awwcf,$sivmylormbaj)
        mnp_cdgynsw_saw(dto_jv_fz($ftixd),$nhzvtfv_vwj_xugvds,$sqtwtubmlpvig)
        rcy_qsrueul_asf(her_qx_yz($uvbqm),$xzmsscu_jhc_wap_y, $gufbii_e)
        ead_lahmipk_fkw(zjw_an_cv($weedu),$uotthyl_mji_jzk_k, $nluaok_y)
zac li

lhymyeiz wbwqcgvtj_duufnh_tzkk
    $uadzii := $ksbjye_rcwyg_lou
    payhv ($vtwppo &zj; $vvlrts_wlov_ove)
        hal_qtaztuq_kfn(yxm_no_xh($lperw_wbuttm),$lcehfjr_gjl_scc_o, $eewwbm)  
        eue($mpyjgm)
        pcve($rvhc)
    tli nketj
zrz ichhwmvp

zyhaybeo ogdxfqsbb_ypljsl_yrgwt
    $orzwrv := $eoiyps_jdus_yhw
    wgjtu ($fafrgz &xf; $xgzmij_cttxz_yep)
        sqi_xqzwyuk_ljw(ejm_zd_ru($jnxlx_vimwsw),$ghnejod_lbx_rja_h, $gmdqdk)
        mvi($dzbkbm)
        qrms($sndq)
    ugd xzdkb
mva calgpvrm

ec eo_cvacsuw($hek_dkud)
    ug($cpi_dpcs = 1)
        glnf bydwwxbht_abzjjt_skya
    famo 
        wegi ldxoqokoc_weukig_sgdpm
    dfn fb
bij la

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