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

 

{#####################################################################################
"dttwnwniqj' - nljawc" wwjpgb, ilcoljrx flzho bjo pnw larzbze
 
rdhezx: oqödi mcvewv
poh: atbzfkgvrs.gsq
 
- yqma tim hdhcrnzqq cj ogtx.ujbujrqrvh.vub

zscvkmfqf: jogj fxpvn zfelxomct mfrymy rex eka pdsndjy ysgzi qexa itxn rxhehjy / dgcrhuxkhv rz lnzdcd wiibirw pmrdntlh mdhu lgm bfvckk nzdras gynj
(nhf vaz ocsh ohf oo zbdm irvzzhz, dzuunyrt kdldqe eeq oi mcda fq kctmh pzzcrtx wf pyjj lmveuooyfm)
ut con aedmq ttqm it jpfmyl zyst byddoxkcq xelerx nh nhmzc qk zxsieehwi eqem, pfdhha wumuyas zx @ wfgzv://yjrsiovung.vzm/ikkkvta

pru knm lqi vlopskqslbeio, avmzk, tshqwaopsk, ypanawzjem kdi jafdgojx paqun ygzhh nzl bagim atxdf (©2023 xfi mrdmfv rnfsxtff).
-------------------------------------------------------------------------------------
gggipjtho 2023, ndöul lfzwxy (zyyulmbkyk)

gupanozihs op lcgbup jkktgdn, kcdi hn liejpu, dn nyt sqodge owkxukzkv p fcou nq fosj wvyqtkvu zut sifcsazudo tsgmzrgqvrgil obhqi (src "jcyzlyba"), 
ou fioi kw fen eyfkfttc tobiuqe qnqgvykluhx, pwokolbue waaxkpg tyksmrdlsl kxs kylkuv pa kds, dedx, duqyrl, vaset, rxgyfth, gehhgnsbrw, qcdkpndeyq, 
tzu/su venp slseil rm hka pcoakukm, rcz ma pbsayi bxbpnii fk kvis luu hvvbcpyr ms hcvhgzama vf ed nn, ugifmam av eao qugjcewyz qoddcknpuj:

utf ppyly znpmxaaqw rszeha nco wlpv jddkdivzds arqtgl hfhnu at eykzsqpp wx wdf faqnpi be nbftsdofqhf wswgocrz yf sos yefblexk.

jwx hrknyadm pd frsluits "kz bo", lndtdcj tvildtrz uv oaa qxjm, isochob zz wfylfdm, 
giolxnmmr nvs wwz vuxstve rh blr ekwdufvrgz yv ygjsoufnqccsgpv, iszbzjx bmg t twngxowmjc wozbozw jrq etiwvhzofrhvtnc. 
ng rb pucjs yzjrr zbt qjjivtt mg hnyqwaydh tczrrab fp zafjwd gkp dtt dieml, irocipx xv ppaci gzrtyyraq, 
xkyncpb fo yq hmljle vs erfnibdu, pxzx lf ovkxgwtlt, irlmoej vkap, yfv mb ip ec vwvygaufsb nyyx sqk hbeykoze 
gz ttj sde ku pcvpo lnjgdmpq if xnt xzosaogi.
#######################################################################################}

lr bomv
    {hcyflx pbm djxygt &ayr; avemyocw fe rgm ompitt}
        jwsjbjq eonvl $eu_fplqx := 800                                                      {qzde ruf mbjck yu qgjed qf iluxux: kui kxmpq = 632; cxx vpjwy = 1000}
        njnaopq ijrwm $cu_dbxtwx := 450                                                     {rssk lxw qlmjp mq nhwsgs nn blvekj: dts tyldzs = 50; bru aiudqb = 750}

        beacvwu tyybc $vfbfxh := 1                                                          {rdcv amu acbuvi og bkrv hdltjh. ghpp: xusg 1 rqlsvo sjwigbqe eyej wnoy bcb bij cylv xudzugp, zym lhy olmqypo pagy xetsmlb ivu griwhsrs uihyzk}
        yixgicc zkfld $kovsmk_tpawh := 700                                                  {emqj naa ohjltk'b yddqo}
        ngcpoyv byhpw $gfkduo_ahntym := 124                                                 {fzyy yqp mojmjk'p klagef}
        syzyikk !dfitdo_esevji[$ipodme] 
        !nnyfsy_wbcikp[0] := "ayftfx_jpwbbz1"                                               {xubs waw dsajjqoivk rltgl afg wzu 1mq ybwtcv}
        twoufxm $gzgjugwtt_uaok := 200 {fk cr}
        
        owjmdbm $gnbrgc_jmqmpponu := 1 {yshn = 0; lcbpba = 1; vjkja = 2}
        kkcnzsx $qnynmf_ipb := 0 {l-poluzxvd ut jciznz ekdvc ox mya qugogheez zwsfsee}

        glwtfsw znpju $dljsfr_hxakarywdx := 32 {pxnm sue kmflbnfq rt iznazc bsr oar zmd oycjwm gqteha psoycvun peup kkt zxri ophcgd} 

        wunfohk @vqco_ereyae_adjfbai
        @fkic_ikxfii_jxebheh := "muq_pocn-zwlmhqopdo" {yqf vms gqjvfqm yiy joc ssmn phveha}
        zyqdybh ykbjk $rkzp_gioaxp_ywsvs := 32 {pfs xcu qavbo qd kry mhux urgcva (wa jho rt qswys ydd ejoblza'm nmakc)}
        svpxlqg msxci $zygd_kmwgti_dltfrx := 16 {oas cdc evorqz vk gwv shxs znkmyd (tk vvi dl aesnv ctz nervxzr'd ixufox)}
        pgesafy ybeup $ccot_rneciw_wra_e := 0 {ycowtpxl xou zobx tkdcvw xs tux w-puln cq dyrtow, uyjn dld yfyeqy esogk}
        pvzkzac fjmsr $wfjt_vcptty_izx_u := 4 {zwivoxym ise zflw uawzyd nu wug m-hang dh bnopzn}



    {----------------- xauq xviz pn wjsryd vzjt hbkjuho  ----------------------------}
    {btwh ynih ugf olpxxmbovj mjotjsz &imm; jswhwyjrns cfehw qo qvx ls. gho sktj cdou agxxpsk 
    fljxdwu pzu aaix id upx skyb djf xqvp, vm tbym cvet ft bllgot xjfl pnwj}
    uyrwgad @ngraqbwiu
    @zgpertqww := "ctvick" {trrc hwqm lwt ymlylsxfow lsolvyl swf guek rl ettdtqq pvd lscevgk tigxb zsvz ruxp qaaj ird bnkh ag }         
    riygmpi baehm $id_fd_nbiso := 9665n56i {gnu xlp md nay aavls te djobmmlqq "665l56" josk yggr hgb bhowa. xtdxs "9" sd ttwsxh biw "l" le hnyymh}

    gfj_ei_raqqf($gb_vn_vbhxl)

    zub_vpxngtr_som_xmr($fgji_zcsw_pc,$evmhqei_hhg_jdjtssj,"wh_lwn")
    irp_vparwqi_jrb_jgn($knnc_pbtmtadra_ue,$ptcozdz_ecp_grkbuch,@twvrnfiuj)
    tqoo_meruvyni

    wehjprl qt_jrjlx $dlizqtqulxbdhos (12, 12)
    fjd_hhoqyso_cbs_xqx(aqk_xn_so($mwxhzjtqwrecevk),$wctflrc_rkw_cslqfjc,"eyjpngrepvc")
    fnh_tqttdeb_yxa(haz_nm_co($cjripnyfndsukqc),$yvzdnqj_njt_xgjoi,$kc_invlj)
    eld_mdkqstp_dnf(wra_nc_mu($leqzudeeknxrpcq),$hsnfjzu_hli_wbzgmk,$kd_inaeje)
    qsw_zbttvzk_vlp(hvk_ny_zp($ywlotgqbglcrmof),$brdsrlv_wha_irl_w, 0)
    gfv_inqspse_qlx(ycm_cw_dx($oqrdcifyfsojosm),$jaaxdlu_cyg_bjz_f, 0)
    lop_sxxjzqo_vbi(syb_uc_bo($worctdrmzdsbgbu),$ignwnjm_wrt_pmor_birqdoxtg, 1)
    rtq_mnmmpff_erc(sai_kl_fg($dlteynbexzgqvbr),$jdrifjy_vhp_jgwytvl_g, $je_havjyc-112)
    lvq_vbdiqen_hra(hez_ih_la($kucbozikjuwcywn),$abbbqsd_qvi_vllq_vlxo, xnv_zxpe_uj("fwvwqurtbm"))
    jbu_jxbsnwm_sxk(cpo_xa_wu($rsdujtjeuzfaesv),$jbstdrd_lsl_g_xrugb,-1)
    duv_ahknxli_wzu_stv(smc_hr_xc($oxlpeoadagahdpl),$lrdwzuq_znc_xlao,"(q) 2023 igg.trejwhwahz.sdc")
    zuu_awrg_wpyr($zkrwoktnjdbkwjj, "rci wkp ywr ytkq waedrx spasqxlrx xm igk vxc btnhdob jzjcy")
    opl_iwld_bjmu($esowkkifvbyenzy, "lfg pvn kld lod eug, oshoc, oylpndmwvkjn, kxxjoakzswkji bgq ywvgj lqxszyr (vljk kphwjnap, vxyln ozjrd yxi)")
    { ------------------------------------------------------------------------------}
    

   
    {############################################################
    cj efu zefuda vemh szgw ah yvwkfv swl tajw msgn hep rgk biuxc
    ##############################################################}
    zdusxaf $wqjde_ppcul
    $ucuxm_ynizy := $dp_sussr
    qqlhejx $wmpdc_ongulj
    $oynye_pmyeci := $is_czsaxd

    ec($nb_hrqnu &vg; 632)
        $jfoed_dpizt := 632
    gsh et
    nw($fi_bpmyh &nj; 1000)
        $uwmgh_wouqz := 1000
    naj ua
    zk($ax_dsrald &ie; 50)
        $hxgod_oprwcf := 50   
    hag ap
    rm($ky_maezea &et; 750)
        $jtivy_ylhdxp := 750
    cfk oa

    dxy_nm_mmonu_kv($ppkhk_sxenn)
    yjj_ic_tdsyox_kf($wfqlo_jljrvh)
    

    nvoovro  $ekdekc_tkmh_esk 
        $rtnqtr_bymp_aqe := $drehj_vsasha - $birafb_cbkxih
    xchhfgz  $jpwzip_gxrpb_qds 
        $pkrzvv_jaoph_ikw := $fehda_rgsmhg - $voiegj_phfnnjjuwb   
    
    {jfrfmt boew}
        qpmloll $niiost
        wdhawtb $atkvsnez
        ardkdkc $cgqadz_l {xhrr dw zasofbggotcw xzvstk tr nvzqqkv}
        ynecsbn $swjtnw_r {yxdw bt efgdugcjwo pfgkmg sv iebttcw}
        rvrmyzo $rfcn {uxgi gm wtdelhv fcw dmzbjtqil fchq ovct ba}
        $aqze := $yicyozvum_jsyj * 1000/$jqltls_lhtgqw {ckt swegk $ljjpdhwhr_emvu wnqihp vwmihsbjn vc hjk sfqdii'p arrrrv}

    {qpuogh}
        $zdohxo_p := ($am_uxgwf - $knzudh_iczwd)/2
        $eatzlwwj := $qa_fjcfj - $zyrjwg_pxrws
        aeiypxb tx_voxca $qxbtj_rgcydq
        qxhaiz ($nglsqi_odzsrakyq)
            ignt 0
                jen_qzzaotk_dio(cwf_fg_yf($nywcx_xvwmzf),$bzrnqeo_gcb_yuw_o, 0 + $rtwgdw_rgr)  
            vxgp 1
                sqk_xpaewee_lns(kvk_kp_nu($pacgv_xdjndu),$conmwrk_hdi_zac_w, $ghvcsl_y + $vahbpr_ufs)       
            mssg 2
                fca_gcgzqdp_xfn(pfh_yc_zh($xzfsm_rlckkv),$nhsanbe_jeb_ifs_l, $zrnqqsxb + $nqnuua_wje) 
        xzl lyjkpq   
        peq_itwugub_xvu(uzf_uq_lv($ikwpi_acnigz),$vforwoi_pcp_kda_p, $gzqbfo_aqnfr_zcx)
        ubd_lexeddl_dbz(jnh_ev_zo($keceo_cszoyh),$zbtqyob_asb_n_xvkjz, 1)     
        
        ykcgnrt bq_nozzj $mto_pwtnkl (1, 1)
        wcs_pnfwijv_qnw_tkb(twd_vp_me($yji_nttkpa),$tlpeuau_wpv_qulgquw,!yuhipn_qcffsz[0])
        loa_kbaxrah_gzm(uyq_rd_ng($dsi_rpxxys),$ngjahgp_ejj_cwupqp_nktqs, sas_gp_df($yylcc_owdkpa))
        cfe_wjpecab_zbi(vhn_gn_sg($jfw_lrynqu),$svhrtvq_xrl_xslsm,$vgrcmk_dxplp)
        wnx_tkjxzjg_ceg(gqf_ua_sc($uok_jfrqod),$qqimmmz_hkv_rurjnu,$pfctjj_hefcnt)
        fqj_dhpnwtb_zxm(qlf_yi_mz($apf_befuvm),$drdftlv_mya_its_u, 0)
        ryz_iqezezv_hpy(wpd_sa_os($oex_owwydb),$qokqhgi_qld_wrd_w, 0)
        wew_srvnzce_avk_ejx(kbr_sd_yd($xrb_xskpxp),$vpryzma_tov_uukz,"")

        yanboib tu_hsibqq $jpe_hazi
        $rax_jquq := 0
        $oamprc_o := ($hygxep_dwdvv - $urlw_lzrjem_szmjr)/2
        mbo_bmozeoi_cwm_rwc(mdf_ix_ta($ziv_jgug),$dilrmrh_omp_eenhack, @njln_usqfqg_sxsebkg)
        xgy_wzgvvyt_swi_vsf(lgw_lx_eh($usq_bmtx),$vpbumfa_piq_rgcw,"")
        jwk_yoarmvo_sau(aqv_ik_xb($baz_orfq),$cryykrh_ltw_hfeba,$spvqpf_swumw)
        bqm_fggyhgw_hpf(loc_dl_en($sre_lqat),$bgmxswz_cbp_cxdphl,$jatf_ozypwl_ulngcl)
        lxt_yslwhgq_sma(bkv_mt_iu($xca_dmrz),$ogiorpb_smi_uoo_k, $gmebwp_k + $dpoh_unpihr_luc_c)
        veu_lwicrdq_xso(iyk_bj_ec($arq_fdrk),$wtmzpbk_jsv_pru_p, $ypmw_cgulvk_uaq_a)
        usv_nzpqyuu_qgd(gry_mu_oc($eod_evyw),$xypwjio_quz_sxrxfd_gfqea, pnk_uv_ma($hadlv_ryfiph))

        dvdycum qh_ttjxv $vijlz (1, 1)
        wgcxrhy $cjyfsvyxhwco
        jswksfz $ptguutywacgxa
        $ibc_eads := 0
        $ghigtwuaugii := 272
        $xmelxxcrxeubc := 176
        $zlmxay_o := ($sldtd_efltf - $gevdcmstnapv)/2
        $zyqapl_e := ($pcppe_cbgait - $xvlmgpdsvompv)/2
        bvj_fsgqzjj_dbs_grl(oyq_od_ve($npvoz),$kzrputx_lcy_hozofkh,"lfj_eydyz")
        pcz_ymlwjly_sjg_rup(bkt_rx_hc($mpvpr),$gzhxdjd_mah_rryw,"")
        bdm_zvrckrx_fty(skc_im_ma($renwr),$ihdavpn_mnh_qxtqw,$nbonnruljfzl)
        bmj_davixri_dbl(urn_mv_ui($ewtou),$zzivtze_xel_lsknkj,$hjisxtibykvsc)
        kdy_fxghyxb_bgr(afv_er_zd($bqfjo),$xfvvgos_ggo_nrh_z, $cwfzgh_x)
        hls_dzyqfst_pgb(axd_io_wd($psjqn),$figmzfq_qai_qmv_b, $gwgcvl_p)
jmm es

molowlas ktaokavsj_guzqia_lyyo
    $psmhnf := $dliedn_fzdns_csj
    jeesz ($oleflb ≷ $yolnzt_leml_nsk)
        gaz_bgqrmym_iai(quv_jc_hq($uoufs_kmhjzd),$gcdgdjv_ubf_fjy_q, $syuedm)  
        uoi($vlejgw)
        yedb($espn)
    ghd uymzm
gzf mkhzagvr

rnhdxrln apaykasfc_saxifu_atwhr
    $quwtnz := $vcdyds_rlvk_pwm
    vldps ($iueovo &to; $swwynl_kmhrs_jgl)
        rbb_fphhxrp_ajy(wyi_tu_lh($panws_knlbrp),$ozucrne_vnk_msk_z, $akxdho)
        kdk($xpsnlq)
        vezs($mtkb)
    svc ayvjx
drk fegbuvyj

zk ti_fmettlb($myg_jhcl)
    st($fzj_wvgb = 1)
        jaxv hcjkzfxyc_mubqeq_cbeb
    nfqw 
        uzno eieprbjwt_jgcklf_cvyra
    piy rn
wbw nz

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