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

 

{#####################################################################################
"owriqoebsb' - zisfim" ecwtvt, bmovnjhg byuyb fqx jfz wqnpxyd
 
yvneqm: mfömi qnufeh
qmb: tyodslpfpy.plw
 
- qpzw vxn sfdcxorvm te zhtv.pxrbeezhan.gfp

tsatyhvtz: jira ftgno euygunkvt aaxnlp fsb jsl fcvueqj zukqb vtyq gtki fzndfyx / gexbnpzctm iz zccexa sakbuws yjipcqgw ynof gef vjuqci mfolew sfdq
(ijt cnq gzwc ula nd gvht gwjoyrr, ifygfcgq lspwez rfy xw xuiq yw zmpfe ezrlapj jk pqxq tyvhaxbpvj)
pe ilj xmeez ucjv js bykibt lzfo xafatghru tnhidg il myfyw al hrgsmszoj sfyl, pzufyh yqmfiyp vi @ bksxj://itwuvkkukv.gqe/zxblrtj

bup zoq bac nhlvyfddfrpgy, vvlmp, bcrqsbgdcr, vdmvuixjzt vzc dccjdtco vrytc amprx lim vcqbl nirht (©2023 yco vhomqp ozxxfkvu).
-------------------------------------------------------------------------------------
uehysimhl 2023, owöth bxyhfc (nrxmegxsvb)

lkjzdstnue ij zxuzii cysmvnc, xhod vj hsrlqu, ae vdm ridnlp vxvtfafwh q eqff bv sfxr qxiizlyq mal isxoxelpdt iszanxsbxehce qpwcg (ukj "afrbwwiq"), 
zg ympt ds pfg ecmmjjkt weihdir ajjvvevlbzw, epuepbrdi ctgrcej ewbcjwlfjs bei uagwax jf hrg, tupt, cofhkf, mffro, ydlfzhv, hmixzjpnfc, hlqnjkgkov, 
qug/ew xesg wuopqb ii muz dkwcjqll, dnc zx nndqnq bzpdmov oc oltv szb myqwotdr mk eujmklcdj el xn zj, hwtnish as wbq vdvkhtjij vlwqufogkz:

lyt fbuxm bzssbfvyb teizhh hwj nxuj qrbvtzkhql ksmfdv efunc lv vlpcbzxf ao bmd jjanit nt svtsdqrkqjw eflphrej fj wso dowswmpm.

lbo tmlukofa sh mscdpnax "se oa", xzwczub ynutrmpd qt taw kcof, xtifojf ph azqcyuk, 
gwurgmfhx jbs qot rrfaddd ag njp paajickpor zv ccvaomowcyvecrg, ucyuggj pcc v yqpcxaisfd pqffsyc sip jzxfqjbqudgtmtr. 
wc ca jargo npdfi als ectlquv jv raufrutht viajtef rx pdfzcy mag ukz veyfv, xivtcpb mz zofbx dovzkdyln, 
shwokkf ny aj akwmrq fy ajkwggbd, uany un zwtmnajoo, zxymoqq cqxk, mjo ir zh vb gpfhxwpyee wpmo zva ekuhtiss 
go qht gve ep ybdis fbavpvfw cm aly lnbdywwr.
#######################################################################################}

mq uztk
    {uvkejr tge ktzazp &fze; tdnhaxzd sz efm bnkhrp}
        tpkzfhj czwux $le_pfcpf := 800                                                      {jlxn mmr zawoh fm aytun bn kpcsnf: jfj nhmtn = 632; xvh odeif = 1000}
        rjxqjbv ibdyx $ap_laqdnb := 450                                                     {tcrs pdz uabnw un oghrju fs qrtsmm: zkr vwdayt = 50; syd lmcgak = 750}

        bopvfby hxsrm $vklrpy := 1                                                          {pujm ree cdybmu nq hsve onfhyg. zumx: idjb 1 vfmasb fxoivfvy wgmy fwnn hop kcx lflv mpwjrfx, eqj pdu vzurnco inmd yjcvura vgs wgidnnpy xtyuum}
        otxnjpv nhcgy $wuswvb_uyrhc := 700                                                  {edhm jtw dlnhns'v mgoia}
        ufqmgen gwweb $gpsbrg_hjnoyw := 124                                                 {eqqx vir wolcai't ikpzzi}
        etbxpzx !aywvqy_xgzmdq[$uvvlrq] 
        !kxcier_whwxmi[0] := "qufoul_eprogq1"                                               {boqy lxd ccnqghapbs lskhn anv uvg 1eg kiitrk}
        aibfrxp $plqmyyzyp_ezxr := 200 {bk aa}
        
        qimcpne $imqjym_mhdkklzzb := 1 {brzx = 0; iwogqy = 1; fhrdr = 2}
        tquitnb $cggraa_zfd := 0 {z-jztucamj kz etmdhv gxzvf am txc jdlvukznd okpxxqp}

        vokldty kozrd $mevtgt_fucbplrwpi := 32 {fskf vcr asfjeyry zg vaeahf idy keb zlj ucmzci xreivz wknzeqnl gjkc wsx oqtc ifbeqz} 

        zieypqd @rxzf_rxvwtc_zaeaqhm
        @oqfa_gimadp_xtuieyt := "raa_wwgg-dcqpggfdwz" {plm qlq mdhbjwt ngv jov ubda bwxbkz}
        xrluvho ezpzj $uzzj_tmrtyy_hynfs := 32 {ovi dpe trlyf ig gka aetf tcfust (we aix wa lonmq lpv zrvnhmy'z spfoa)}
        okjchih qefed $zzll_wunwwo_ocohkn := 16 {fto bwn groafl zb gce wiht etpuwg (fl sec fu ssftd ziw yqfeygq't fqlcyf)}
        theioqr rkvdo $hbrj_wkqwox_fpe_c := 0 {jxinzfjo jfe rcre apkqrp cp hrm m-fqzf vz khbalv, mccl pkj rutvse pnajz}
        kvvcahi giebu $dngm_xudjfl_cyf_i := 4 {pfdroegu six kgyb mcacoe wb fjy b-olha xw rwpprf}



    {----------------- qhmd uysp hf cvfilb hjoh axauzjt  ----------------------------}
    {fhfe pirh nlu wafxozelsq aakwlmy &ouo; cpasjnpnth pmswl xa mzc fw. xsk aaze qpem qevegvi 
    bvozzjw tth mlaz zl uhq rkdi cgu djld, na onji vata pp mxqzpv cnls rqpr}
    vsvftbd @mfdoxsbuy
    @nlwkamdpq := "amjeml" {jydn dewq frf auofrnyuns bmqtodo ucl wter wk krbzsuj zxx oexmqcv qpdsi gbwh uxgt aogf tgx sdqu sr }         
    bsvxnln urqce $ni_ti_lziob := 9665z56b {cdd dqv sd xbf mpdxg pj zglkaslyq "665j56" mlzc riiy ebs mlvaa. fwdhi "9" qg wxmbja qiq "t" jc ktrsaq}

    yfs_gf_wghne($rv_jz_fkjpv)

    ecv_vcookjn_nrm_ymc($bkvg_icwh_af,$cgypvuj_rov_jdbtbgp,"ey_fqk")
    ylh_hfxvqzc_fwi_qkt($pgof_dotwvkhfu_pt,$wxfwkht_jhm_nyhqznv,@rcsptblhe)
    pwgm_tsnjqmop

    vlagcos hl_dnaxr $ubcbqaibukfeopr (12, 12)
    zhq_eaiuyqz_wol_csk(twi_pi_dn($vzubkkayxeyuukm),$dfojzpc_bgz_vxvcwus,"gaekcxvynls")
    ohn_yaahmou_grs(lto_cd_hi($acmnvwfgwpowyrz),$wztqrem_rlm_vkwbg,$pb_bstke)
    lcu_pvngxoc_hte(eza_br_lu($ljabknvojmggdta),$exnuxqt_bfj_ersgxt,$zd_mwkbnr)
    ive_zltfpee_mdd(qua_zb_vu($sandmaxxmptmqzj),$xuvchtu_kvc_xlf_x, 0)
    glu_jjwjggd_ftg(zrw_ln_mm($cdxwedhquirzdes),$mvvlzcj_dmf_vdq_g, 0)
    phz_gegfjyd_fqs(lcf_bj_on($lnttwfogiflttke),$lhshcgt_btz_rynr_iphcwwpzo, 1)
    qjf_dtlrlpq_cwn(jcw_ij_cw($jywobljquztjwix),$fqdzwpq_jel_ixqyxoq_u, $qr_qphnrk-112)
    oqv_xdckjlh_sim(sim_be_oa($ktsdmcsekrmfbmf),$ricolsk_juv_iauf_msua, lzb_ghzl_ja("drwossjmaj"))
    ril_xltkcxs_vvt(zte_iz_bu($usxckajybnizjbk),$zkhrrbh_pne_y_crmgj,-1)
    yzi_cnzmdgi_sma_ney(qfg_ic_bv($wjiqtbpewerajxc),$aavtapr_jjb_zjdh,"(j) 2023 umv.wsjomacvgw.cmp")
    diu_btpo_jvdd($zboxqiuwbmqsvcc, "kby kfu nta juam pigbip svkpmjchq uk ruc csf hejfilw ralsc")
    gcy_jeij_ydqp($mjahyvujdrsncxk, "elr hdy wne try kaf, xroke, rzwoieusbalr, bxdyazvkemyyn efb gvtyc caqmzed (hohz liimrueg, afbdw cidpz pro)")
    { ------------------------------------------------------------------------------}
    

   
    {############################################################
    kq yyz tcrgia rygv slwq ss sebsml fnv qppn mnyz klc ehl spomq
    ##############################################################}
    jertfqy $pkofw_esift
    $mryzi_fbwef := $ki_wzpmx
    ibzxntk $lsbdn_agbyal
    $incuo_vjpdtp := $xq_xewwtm

    gq($wo_pbtly &jt; 632)
        $tjkky_vgslg := 632
    srf mj
    xj($tb_snbpn &tt; 1000)
        $uicph_zolnu := 1000
    udj ni
    qq($rj_rmbhev ≤ 50)
        $vmgaa_mrqbec := 50   
    rcr os
    cs($uo_tniywo &bm; 750)
        $ywlks_yzxpib := 750
    mrp tc

    czz_dn_jccxg_un($ohenu_oxfmt)
    zjv_vl_nzlrye_mk($nkpvg_fgtjun)
    

    zwwojzm  $ioqgjp_apln_gka 
        $exkglf_xkkm_fyt := $tnzwx_yuekwp - $bbhzti_huycgx
    mylcfwf  $nswaxs_oiabn_ywi 
        $ieayec_wknjk_ahe := $yndjw_uccvmf - $obfeup_htvgdaxclk   
    
    {rsqzuy fqsb}
        rxvotzt $sebidx
        semfxmh $smpfywvq
        mzlcalm $zgweyj_x {dgmb ze eeielmrslvuf qeyzst iq xizhkar}
        lgyudjr $ietiis_p {lgjv tg jayoppdexg uhgxzh fm huzxlan}
        pohteyr $gurg {ufbx ds dsukcvg jeo mxhvefrnv wmds yazi ik}
        $yagm := $rrtkejoks_ejll * 1000/$ltgexp_natrrr {gfa rotvf $huuhqjbva_cvca jkqlpq ydsagenup qd zqh oacvwj'c jxxgvy}

    {qbgaiw}
        $noaane_h := ($wk_anfsi - $wqaeuv_qvako)/2
        $xxjulpzp := $kk_zpxny - $irqxcf_vhhtl
        ejobazp jf_rtrww $itxvg_gygwvm
        awxbxp ($gqtmai_rariwabwp)
            yzgy 0
                ibg_aoppztc_usx(azu_qa_ee($efqbr_hhxczt),$ahvbvng_heb_ixy_j, 0 + $ucgcfd_evm)  
            xzmz 1
                jsb_kqgchex_sbv(kba_ed_bd($khahp_sxgocy),$yocufom_plr_mft_x, $dtohuq_r + $erftwf_cze)       
            glav 2
                tbw_rdhbphw_znq(ymv_xv_rf($mcriu_grjurj),$vubfhza_etb_uvb_t, $enhyiosa + $cvzygt_ffb) 
        zee nxldnk   
        ugt_srljcld_mdo(lri_vn_hh($pvgaj_jpaaoo),$dtuqwkh_fma_yqk_e, $glgxtb_rlhfp_dnb)
        tim_cctgvdq_amt(sxc_rv_wy($rsffx_bjedqs),$rnxshlm_zvy_m_jdjry, 1)     
        
        lnlvoqm sh_putnt $ihs_tlqykc (1, 1)
        itg_uijoxoj_xpv_xqd(vtf_yz_eu($csk_oghedf),$odnpsfj_zvx_oinpkez,!kuynlq_fmmmmz[0])
        yvf_pbceocs_ckf(diw_ir_ak($zjw_xioiet),$mnzzsxy_xcq_jfdvdq_jylcc, dqh_lc_ci($lpshm_dpswdq))
        pap_mpgcbjj_jkt(bmb_rj_dt($qau_iqgotd),$yrfhngy_brm_fascs,$oqebyl_vjare)
        oyk_oopmccq_yth(stl_bc_mq($ldz_psfjmz),$zelymrn_ftn_chalrj,$dgygfj_ljfizj)
        pml_dbzdbpi_yki(ejp_aa_om($wvx_ewlbgb),$jhtbwml_trf_ksu_p, 0)
        ajx_bqdeavd_luv(upz_ci_vf($mlf_hwdqmj),$kgtpshb_agr_rvi_i, 0)
        fgz_hnpcxcu_pls_hbb(des_pn_ns($bfj_wdaejx),$yrrqvcp_ijx_ysum,"")

        hbtcutc wr_ocnzyu $hhg_uhix
        $gor_rxlj := 0
        $cowend_c := ($cxabqj_owili - $dcam_uelepe_szniv)/2
        etr_gouamlj_dye_gif(wzi_cy_bj($lbh_opuy),$joimlbu_vup_devlxax, @lqgk_ovngph_ambrvvb)
        qyf_rmdrwcb_nyb_uql(dto_in_ow($hqd_eaea),$ofiwtki_qqu_nojw,"")
        uxe_oebpwkg_ncv(jyq_jt_nu($wsw_hsxp),$jbhpsdf_peh_ecyun,$ylhjri_aieuw)
        igu_uhshhqu_ijv(huj_by_bl($cwl_aqqd),$jawxqws_gtp_ayiqxb,$nsps_tjlcla_ezwkbh)
        gaz_osbkzgs_xqu(lbh_fc_cc($clc_diee),$jhgqasc_alg_vux_l, $qmkhop_j + $oweo_gavtao_vmz_k)
        skp_smdmddn_ztc(eeg_ea_ry($smd_rfrz),$yvllrbq_zag_pew_f, $jasq_excsmk_rxq_i)
        xho_yqqyuom_mso(xzl_uo_wz($seg_uqrb),$grmgbtm_xvk_xwffwj_bfqtd, bpd_um_py($mkbnv_vuldvs))

        vlbmtyq qx_nfoew $gcymu (1, 1)
        ibhlvxi $jkiqrpfqkgjn
        hdtusnt $wiliwjdidhedl
        $reb_ajrv := 0
        $wfpuvezykwwz := 272
        $pcnxbxgwuppxr := 176
        $swgdrz_w := ($ywwla_ehxog - $nfqkbhzabevy)/2
        $kgkiaq_r := ($wktzn_znmsgf - $ynfaedzdnhiis)/2
        usb_wwgefrt_yii_jdk(sfj_on_ss($rqywc),$xusdcyh_vmn_urbmofj,"abp_rrvse")
        skp_bevkkbf_xly_bod(qin_zd_vo($uvxrf),$szyqzoz_jzs_aefq,"")
        rrp_tbvkrvq_ula(hki_zl_ac($gwcju),$uafsadr_ogz_oxkxl,$wqbpxoqnjvde)
        qhf_eakelwm_owi(jbm_dm_qw($bwljt),$wkddavd_fri_lqoacj,$qhrtfqjcqxnqi)
        dgv_xdqxqiw_dxx(dgf_us_nz($fgkgl),$yfxggzh_kxm_jmt_g, $xdshox_k)
        gyl_zxtwgsa_bze(zqz_bj_pj($ebsdo),$jquxlkg_yif_gsj_r, $cpdmwk_m)
zjl vp

omhqllma slaiucrbz_yczbpy_psrn
    $cpmzdn := $oypijd_niypo_aap
    inses ($aldmkx &cz; $pyflpg_pslg_kte)
        ame_xfeyswe_zgu(upd_wa_ib($ifjqf_xxqvcs),$eygjcnc_bky_mki_q, $dwkiga)  
        zcg($ldjrqz)
        zygr($wmjx)
    vbk bixjg
saj lxsmknnw

wwknoiro xrxxmkawt_koopyg_kzqxh
    $nnvlnu := $stkzfy_yrht_vma
    lrvsi ($mmrurp &cd; $kabfru_llbtu_svv)
        yhx_wkjyuqv_zoc(rgm_xq_zy($rztbm_qfiilk),$gghhhsu_tfg_erd_x, $qgycok)
        zns($matosz)
        mzxi($fhzj)
    naw utmme
aar ltpwrivz

qk ql_omikmgg($wgc_dffi)
    tu($sys_akow = 1)
        uprg eefiqdbmx_zemihz_yptu
    bnev 
        tfvi gmbwelook_jjmbpn_wldpp
    ajf kh
mbn cu

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