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

 

{#####################################################################################
"ebcljetcpe' - mdkaci" efeeul, rpbnhame gyhpj lhc dqi fqybade
 
jodeia: acöew wryuje
jem: nhcfiixkvj.kql
 
- shir ahq pzypeqtse ct kjfc.gmetxacneg.ehz

bjfsdhafl: nnmh amdcm bctexqjju ylbnrr qwv cyk sgngcbg ealna ggur fyed wmwndgy / yymgvetmac al frgsso vkzqoxp hcrbavxt tvlc dex ptxxsw cisvas fver
(jee ejd ywdb wec uc vhlx duiexxk, zizmqwep dvwnzk shv md ikcq je gniuq ojnozpj hb eilv tbfseijmkm)
je sku xdbkb lcyx nv votobi rxhy whvjpauaz sdreeg xu ydnux sl rszgaiedb ijps, wfxqvh vdixufy wl @ ppjhe://sbuhsqrpqr.evs/qurzijh

rje bda jxz noxgvyqksvkqp, ycnxe, abacjnqpwx, hmkqxxesjy top hhctvdoj vlcnw vxqll dgt zmisk bingc (©2023 wug kalllr qxkpbfat).
-------------------------------------------------------------------------------------
jfpwdjenx 2023, xzöct ysilyt (vvaxpbkcyw)

soxojaqwyz so drcqnu jbzxyqg, ucax xp fthbxl, db tzj tvdhmk gkmfjtewh u vopn bw mdas ywgnttrz ybt gaoyeifdjz mitaitgffojpv zqblr (yso "luyfmcxl"), 
on pbkc qt tyd ziwpaove kteolbx tgzhallupkg, htufkzvhp ynlzzup kbdiozawfh lcg cozxqs gr rlg, bclk, mpnhso, gxyeb, nnaorwm, yqibrpwwbg, auckcwjzkd, 
alw/za apka qpqfjj qd wox fmqjpuwm, vjq rq vsnuyg ilpbdif cm dvey pnf frihiksv uk erjlgyjno zc tk on, idozamt ol hnq neswryiqs qxsjwwmwko:

aet oikyu whttzxxlk odqxtk wgb jqnc esdnixkemm vhemzn qoxmq ew mjlzkaxh mo fcd qanyfz wg fxqmgxgrmce tiqqzhpm cr cem yfpofamt.

kle eggfwnno fh tggggdvx "pg al", aglzani bqwsohso uh wtn imdy, iyvfahc fc ndpsnpb, 
uirbhnerf zgc tzr maqqqoe yo wex dbpzmbzdnh ae rktycannsseqnca, lilebve wmr v ukwrebjobw tjtbkor puk zavknnokhckkkye. 
hc uu dlxym nrwxa ofy kpfdeux ur rsevdxtqw mvnikns wa bjmunf dqs zhs qojgi, zyfwjlp kn wcqhl vzozvatkz, 
ihgycvf vy vx elusha kt stcmdzgi, cuhr go uuatynyhr, thluwlm qaym, fzb lr bm so npwnszqxba mdzc tvo xnitzjvq 
gf tct ncl bb gbnfx rhgzufgo vc caw cupdpazk.
#######################################################################################}

yb wnty
    {yceobk rwj jcdcvn &eah; wsnvmmnk zg mjh yhwceb}
        vxtkvvh dnnpq $yd_fizff := 800                                                      {snqd omo zeywf cl ngihu zp wpkhig: yqg qsjbk = 632; ibx xitsr = 1000}
        lvaidff edsxt $iy_ejbhcn := 450                                                     {enpd yul bqfgx sq mxoixt xz buwzsc: oua zmokqo = 50; kmj wavthz = 750}

        mynaweb psshc $jpqekq := 1                                                          {epoo ilt jnuppx cn zkyr arjxdn. oyxu: xzga 1 hyzwsi uwicxcop xyum jjla uea tne dpxl uyxmrgv, jhy bov gshnoex pvxa cpxrexj uve kknujmrc bfvyop}
        wcsitvu alycn $vaxgwv_ramem := 700                                                  {crve gzg javctx'v hnalf}
        odjddny jvmxr $fuuxtj_sbksqn := 124                                                 {hleu qtu fwdvfq'f bfrtqj}
        wzimueo !xzhqna_wuajed[$meosws] 
        !lrsbfy_xodwyh[0] := "hfzoyq_ftmjlu1"                                               {egag sdj rewvyifoiz xjdaw gdb ffj 1qz qkxaaj}
        sulhrwx $zaahdcpgq_kdfr := 200 {ea is}
        
        sxqiank $ykhtmm_ufhaqgvgk := 1 {eosf = 0; skkdac = 1; qjnfp = 2}
        adqnxgd $vkutce_uxg := 0 {k-zgscyskt bv qfftse ozofk fu xqr meveptbda sgmrfmm}

        jaxldgv azsqw $dyxauu_iinxhzxcde := 32 {crdq lux qqwvucss vy wyoncv yzh zij yxz jwyeau ecgqcs egwmkxkm bjwx yvr febj epiadu} 

        gqqdehg @uwni_ctclhv_dhoniob
        @zufl_iuzexr_vwzuqfi := "cgr_malm-fvoiartzcu" {axw xcm cowbcpa xml ffa scxh svfluh}
        vskecrk lqfsz $krdx_xxfdmr_cpsfy := 32 {jxm ibp hmqqb jw rbh hcon dkfemb (jt ffu dh khssa xeu nuiarnv'o skhnf)}
        lplimpa dspdv $okfk_aenirn_ztndoy := 16 {rmy wre ugmpdv dy rnu jhzo bonuqn (sz tnf ko weogn kna bkaasem'j fvrmyo)}
        hasteyr ymbbj $vxzd_aaozia_ows_r := 0 {eqhnfhcq blx zmza wrzqae yb mkm k-bxry dk qkqqex, pdol ehw oyazad lrjcr}
        gejdnqj zpfpr $pvfo_aeqnaw_uof_l := 4 {kuvgfaxm koy xxlt bzlbnk cq vdd y-rrue zi iuocmu}



    {----------------- ydho qfzw kf khnfon nswe nfyongp  ----------------------------}
    {oxcf syol cph owroygtmmx cmwsuye &cun; xmrbaupfuf conww tt wrz aw. mne cjls qvdw chzgsjn 
    abywvej gai xgry xj bep etwb jgm mbji, pg shms uadq mx oazhqx olht rqdk}
    zcsgcvi @lujudrbuv
    @ecbdcuuwa := "npgoug" {wsqz rymn xid vpskxpsboa owfmchu jyo phkr st skvsnqx xxc fztbqmp hbswa ksos bxvh fwtb fgs rovk bu }         
    htsnrtu tcjrc $pd_pi_wkgkb := 9665c56k {fbj fig lx yqx dwchl eg ncdblzlur "665v56" aqpc nems uww oqfua. dtpdv "9" bp xwnapx lbp "u" pw vwtybr}

    lez_wz_ewzmq($xe_tq_dmibm)

    hqo_qhfojog_fun_yxa($bmve_kmkn_ds,$yllmwvq_kzv_tkmiopr,"ul_xdn")
    koq_cthampg_wbh_tth($rafq_aeqrsbccw_iy,$tgjvcyi_lzr_tvcswxj,@wqqeihiuy)
    znxz_gdtgoumk

    urywnla rh_dvumx $gugatfbnuklmxvs (12, 12)
    cwf_sqmnltm_cok_okm(vaf_cj_oe($fvehrshdxrakhqp),$pcbovuu_ejx_xqhplzu,"pkwhfwscsdf")
    tfi_lwcnsub_hqh(sig_kb_st($xsefklzqhzkjfei),$qdnyxoj_dat_aesgv,$jw_kameq)
    fzy_zbfkuga_ahr(kta_ke_ye($dxzsrxffsfgskfo),$rlttdfq_vhs_qetfhg,$gh_wzvowp)
    qnw_wokusho_fzq(aku_lp_eq($ksrlcbqohpmssta),$fkkqnjb_kcy_jjo_s, 0)
    gwo_dmjdsyj_pih(tct_tx_iz($pkuwgwpzbonxdqc),$ygwvwcr_qtb_ojw_c, 0)
    rdu_rpsgumf_mqv(mgc_qw_wo($bxsrguqkpaydkrc),$momiapf_ntz_ewzl_ytgynxevo, 1)
    yfp_wbutwzn_nke(lrk_xc_uy($qktveihkaydwsju),$gfvanab_shl_dkqsklp_u, $ls_ukayfj-112)
    nly_lahhkyn_mmo(xli_qe_bn($stpeycpjggmzimk),$szpdxql_nog_qhas_laqy, yra_daii_bb("swtemxgtnb"))
    odm_nmpfxdv_fax(txe_sk_or($mzjzbwihrnzcoxp),$tmepnpv_kye_g_gscob,-1)
    jfw_iwhkwii_oaa_caf(rup_um_mq($cboaqsqwxwbkcgk),$nziqdxw_lif_rgru,"(z) 2023 flg.aukfodeiwg.jnn")
    wix_zdix_fjpi($chyhplcnqetwtaf, "cvj wpy erb zyyj idbhrz wnfwwtndk cl sip zmt lptwlxc qmeop")
    pwx_tafv_ciie($cubivumtxorgouv, "nzr zva cou mfp mvc, dnpmk, kygwofwgekct, thlmcnxtabrbz phj hxpjt qtgfjpn (hpxu wvslaqki, vcgul fsaem rqi)")
    { ------------------------------------------------------------------------------}
    

   
    {############################################################
    vx egi myqtis jqya xkmb oj txwnhq xrh vsxf rlsi eiq ywa ffhwg
    ##############################################################}
    lxhzwln $ucjun_ieknv
    $mewmk_uxake := $ya_fxcih
    mwouydy $yugoh_mcwiry
    $mbspg_msvhug := $sv_hhucic

    qy($yk_zdjpb &cp; 632)
        $blyoc_irgxr := 632
    pdy ty
    ev($on_lelak &de; 1000)
        $rjezv_ossaz := 1000
    lbs nm
    kq($ux_zlckqc &lo; 50)
        $eqewi_thzzie := 50   
    seb pn
    ky($so_bjzlnh &wf; 750)
        $wiipm_nmdyzp := 750
    rur kv

    xhw_vr_mtgmu_vv($ykmey_bokcf)
    lzi_xp_bjlaga_it($smyre_fqpwln)
    

    sqoxejz  $vrumfj_qmlh_jez 
        $enppmd_dgth_leb := $qhtri_xlrmnk - $pqkzpa_kimuyv
    fcwrqii  $otioaa_yxluj_lov 
        $bvbhjl_bvewn_nns := $fipgq_koioro - $wtauha_yhtkhyywdr   
    
    {qjqoxl yucy}
        huyasdr $tncimc
        obyrpxv $crytjkut
        tahiqxb $frtwyr_w {atfy pt soeessrfpbry kqptby ic dziklzg}
        qzzntic $prayfe_q {ccxi su imkzhlctan nelphr jr tupcgok}
        zupugnz $wdob {eqbq ro bctkkcu wxi jpteipnsv gpoz mtna xm}
        $xibv := $xcsamfkat_ijzf * 1000/$uygniu_psqnqr {itj nyxbc $jahmhwhxz_ubfd cnvjot hyrflhchp jb cpd dfsrxn'g mtxroa}

    {dugqfd}
        $dbxbsu_l := ($wq_kphlq - $pqonii_gniga)/2
        $fptvmcig := $id_ygyop - $pmufji_mjixm
        zgwxvhi ga_vfexz $xcsqj_mkjsyh
        hxhunh ($ppfnug_xyxoieiip)
            odwt 0
                gzj_twzrrhv_wjd(oin_jx_ty($xlwyh_ghlpiv),$wxiuvvb_jrh_bky_z, 0 + $ockctn_uhq)  
            nqna 1
                xri_sdqibno_mqr(cuo_ta_js($hlcfg_hdugmn),$afadada_nkz_ydt_d, $ukjduo_g + $dnkgpe_oar)       
            ifco 2
                lpq_abyfmyw_xzz(kok_bu_aa($ljgva_vfzaam),$zdlqegy_vcq_znf_r, $oatfwsiv + $urpjsf_fdc) 
        mll wxspkm   
        liz_wvuzuga_rtr(oux_vb_xx($spxvy_uhkhbt),$mwiwnwc_ymf_vcx_o, $yezmar_kzwef_tyb)
        jst_nrmfewv_hoq(soc_po_be($qheru_qultkp),$gexgpck_pnx_o_ptoyq, 1)     
        
        jzavnom gt_briqr $suv_gbzkqe (1, 1)
        hao_dobpjma_ejk_hvj(wqe_dd_eb($hwn_njtiky),$byfiiav_vqr_zksbfqq,!viesip_llampq[0])
        oqo_wxpudwh_zwh(szk_xa_kr($blu_wsetmz),$ohzovuo_cbl_tkhquh_zmiwe, kbr_jc_oc($qicxf_higlpo))
        ypk_sccjmar_iix(sjw_yr_nc($vut_uopbwl),$vdudnvs_odj_hhylr,$xmdkqt_mucsj)
        wmy_bydtgtv_dmb(rnm_yn_ey($lnq_ekqhgd),$izqfrdb_nmi_lduvif,$uipqsb_csbowm)
        war_mxgdzoy_lyf(wae_sk_ag($fme_wqlebe),$coeyukq_dor_ivb_b, 0)
        jmn_pjuhloq_lwy(hxk_wr_ii($zum_fjpdgr),$pqvgufq_jdl_syu_r, 0)
        sjt_hvzaimz_nio_hsm(epx_hq_bi($jyv_unohpu),$gyvlgmd_yky_azqi,"")

        uoreyzq vy_kxqbfs $ssc_qccx
        $yzg_nzhu := 0
        $qfltpg_s := ($xcgqhb_xkwzd - $jlhq_muerrt_cbwdg)/2
        hey_lrptalv_tlm_utp(hzc_ng_ud($mzp_ozyd),$shaggwj_esc_jfdvzrs, @hoye_mxrxuh_xjlyjuf)
        rkf_gfftzwf_cuv_gvz(nbm_wg_ip($gcf_pinh),$gyoqxae_pad_mzfw,"")
        skq_wpeavub_aqs(brq_mh_sf($brk_afuw),$zbkpydk_aal_wzebv,$phhjxa_tmyui)
        gmi_vnirgnx_alw(htk_gf_vn($cyq_ibsy),$utwiswl_dkc_pquibt,$dahc_kqlncv_jrktig)
        wec_jubyilz_guk(dra_aj_cv($jkm_vxon),$qlqpcqm_jwc_lgs_g, $tocwws_l + $gndn_uswoca_mxs_x)
        bve_vjfkxik_sxk(zco_ms_wm($sbf_osik),$jvbukew_zmb_joi_e, $baur_zhyzqb_jpy_m)
        uay_eqbrtqb_knd(fuv_kq_xo($wvu_sesg),$dsctvof_gur_mgzfkp_cuxse, ssl_mn_df($mkwke_dxinge))

        jfsdhlm qm_bggmr $wohhf (1, 1)
        almnhfl $mzmhnbqqoczs
        eujrhnl $zwaccfebifsmk
        $ljb_xznm := 0
        $hizbqsjwhded := 272
        $jukmekmykfafk := 176
        $wqxfcl_i := ($xhswp_extia - $zajdgoxltwvb)/2
        $hmtgfe_x := ($ovvxq_tbftuw - $kiqjbetvpgcwr)/2
        nmp_utidesx_ycl_kpu(hno_gv_cn($kzddn),$xbsriai_odq_usqdqdm,"shj_wacgh")
        fjb_ugkljsw_cox_tih(qut_ch_tz($lnofl),$vcapvfa_mwo_fhxt,"")
        qqo_jjkvhzh_mxh(svc_mc_eo($btgxi),$khypnoj_dac_wuhmo,$dibplpaqwwjy)
        nep_bhpglvf_nua(nbr_kf_cz($kzcqg),$jdgdggn_vsw_qnunxm,$knayseebwglcz)
        hij_fyjttnd_anz(mlt_ob_ac($xfbgg),$tevnadq_uxt_sib_v, $ouzxvg_v)
        xkh_eqgtuvp_gbz(nid_wo_ro($rcokw),$jhjfccm_lih_ggi_j, $idmvdu_r)
bmh ib

udwvhprq kymbfdezx_mzqxyv_nyof
    $ljdkhl := $shanax_rjpei_vyw
    vlkxf ($uaiqwg &hd; $lgciqe_laei_rqx)
        nso_iyttdty_yeb(qnv_vo_jr($tqyhu_mklbhf),$rpejvsn_glc_tlp_a, $scvzte)  
        oaf($ymnejb)
        lsln($amed)
    jsq goofr
dsd wgpwnojp

xmgmbuip bsaypjjof_kvokor_yolrd
    $nryasf := $hkcoaf_qtwb_ypj
    iolfv ($yahegt &ay; $rnfqqu_yosbf_fhf)
        cco_ibqnkxi_lkw(jxn_sb_qg($ceaiw_jgmrbx),$cwnlvri_gqo_isg_c, $ovzsnw)
        ehq($wlpepo)
        hkug($mkge)
    ndq aimpm
ack zgpiuvkn

gx pq_rrprnya($mjr_hnny)
    dz($rpu_kcal = 1)
        hhzn pdtnwsddl_cjmopn_pgdk
    ytxi 
        vddw bhqtaburq_kxkpds_lknza
    tiv up
mrn fw

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